Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Hinzufügen der Facebook-Like-Schaltfläche in WordPress

Hinweis der Redaktion: Wir erhalten eine Provision für Partnerlinks auf WPBeginner. Die Provisionen haben keinen Einfluss auf die Meinung oder Bewertung unserer Redakteure. Erfahre mehr über Redaktioneller Prozess.

Möchten Sie einen Facebook-Like-Button in WordPress hinzufügen?

Mit einer Facebook-Like-Schaltfläche auf Ihrer WordPress-Website können Nutzer Ihre Inhalte einfach und bequem liken und teilen. Sie können das Engagement erhöhen und mehr Follower gewinnen.

In diesem Artikel zeigen wir Ihnen, wie Sie den Facebook-Like-Button in WordPress hinzufügen können.

How to add Facebook like button in WordPress

Warum einen Facebook-Like-Button in WordPress hinzufügen?

Facebook ist eine der beliebtesten Social-Media-Plattformen der Welt. Viele Unternehmen nutzen Facebook, um mit ihren Kunden in Kontakt zu treten und ihre Produkte zu bewerben.

Das Hinzufügen einer Facebook-Like-Schaltfläche zu Ihrer WordPress-Website kann zu mehr Engagement beitragen. Außerdem ermutigt er Menschen, Ihre Inhalte auf ihren Facebook-Profilen zu teilen und neue Nutzer auf Ihre Website zu locken.

Sie können die Facebook-Like-Schaltfläche nutzen, um die Zahl Ihrer sozialen Follower zu erhöhen und eine Community aufzubauen. Er trägt dazu bei, das Bewusstsein für Ihre Produkte und Dienstleistungen zu schärfen und die Konversionsrate zu erhöhen.

Sehen wir uns also an, wie Sie eine Facebook-Like-Schaltfläche in WordPress mithilfe eines Plugins oder durch Hinzufügen von benutzerdefiniertem Code hinzufügen können.

Methode 1: Hinzufügen der Facebook-Like-Schaltfläche in WordPress mithilfe eines Plugins

Bei dieser Methode werden wir ein WordPress-Plugin verwenden, um die Facebook-Like-Schaltfläche hinzuzufügen. Diese Methode ist sehr einfach und wird für Anfänger empfohlen.

Als Erstes müssen Sie das Like & Share-Plugin von BestWebSoft installieren und aktivieren. Weitere Details finden Sie in unserer Schritt-für-Schritt-Anleitung für die Installation eines WordPress-Plugins.

Nach der Aktivierung können Sie in Ihrem WordPress-Administrationsbereich zu „Gefällt mir & Teilen “ Einstellungen“ gehen.

Like and share plugin settings

Als nächstes müssen Sie die Facebook App ID und das App Secret hinzufügen. Wenn Sie diese Informationen nicht haben, führen Sie einfach die folgenden Schritte aus.

So erstellen Sie eine Facebook App ID und ein App Secret

Klicken Sie auf den Link „Neues erstellen“ unter dem Feld „App-ID“ oder „App-Geheimnis“ im Plugin „Like & Share“.

Dadurch werden Sie auf die Website Meta for Developers weitergeleitet. Wir empfehlen, die Website in einem anderen Tab oder Fenster zu öffnen, da Sie die Seite mit den Like & Share-Einstellungen in Ihrem WordPress-Dashboard öffnen müssen, um die App-ID und das Geheimnis einzugeben.

Von hier aus müssen Sie einen App-Typ auswählen. Wählen Sie „Business“ als App-Typ und klicken Sie auf die Schaltfläche „Weiter“.

Choose your app type

Als Nächstes müssen Sie grundlegende Informationen über Ihre Anwendung angeben.

Sie können einen Anzeigenamen für Ihre App eingeben und sicherstellen, dass die richtige E-Mail-Adresse unter dem Feld „App-Kontakt-E-Mail“ erscheint. Facebook wählt automatisch die E-Mail-Adresse des Kontos, mit dem Sie gerade angemeldet sind.

Es gibt auch eine Option zur Auswahl eines Geschäftskontos. Sie können diese Einstellung auf „Kein Business Manager-Konto ausgewählt“ belassen und auf die Schaltfläche „App erstellen“ klicken.

Enter basic information for app

Es erscheint nun ein Popup-Fenster, in dem Facebook Sie auffordert, Ihr Passwort erneut einzugeben.

Dies dient der Sicherheit, um bösartige Aktivitäten in Ihrem Konto zu verhindern. Geben Sie Ihr Facebook-Kontopasswort ein und klicken Sie auf die Schaltfläche „Senden“.

Reenter your Facebook password

Danach sehen Sie das Dashboard Ihrer App.

Von hier aus können Sie über das Menü auf der linken Seite zu Einstellungen “ Basis gehen.

Go to basic settings page

Auf der Seite mit den Grundeinstellungen sehen Sie die „App-ID“ und das „App-Geheimnis“.

Sie können diese Informationen nun in den Einstellungen des Like & Share Plugins in Ihrem WordPress Dashboard eingeben.

Copy the app ID and secret

Beenden Sie die Anpassung Ihres Facebook-Like-Buttons

Kopieren Sie zunächst die „App-ID“ und kehren Sie zu der Registerkarte oder dem Fenster zurück, in dem Sie die Seite „Gefällt mir & Teilen “ Einstellungen “ geöffnet haben. Geben Sie einfach die „App-ID“ in die entsprechenden Felder ein.

Wiederholen Sie nun den Schritt, indem Sie die „App Secret“-Daten von der Meta for Developers-Seite kopieren und in die Einstellungen des Like & Share-Plugins einfügen.

Customize your Facebook like button

Danach können Sie wählen, ob die Facebook-Like-Schaltfläche zusammen mit der Profil-URL und den Freigabe-Schaltflächen angezeigt werden soll.

Es gibt auch Einstellungen, um die Größe des Facebook-Like-Buttons, seine Position vor oder nach dem Inhalt und die Ausrichtung zu bearbeiten.

More customization options

Wenn Sie die Profil-URL-Schaltfläche aktiviert haben, können Sie nach unten zum Abschnitt „Profil-URL-Schaltfläche“ scrollen und Ihren Facebook-Benutzernamen oder Ihre ID eingeben.

Wenn Sie fertig sind, vergessen Sie nicht, Ihre Änderungen zu speichern.

Jetzt fügt das Plugin automatisch einen Facebook-Like-Button zu Ihrer WordPress-Website hinzu und positioniert ihn entsprechend Ihren Einstellungen.

Du kannst auch den [fb_button] Shortcode verwenden, um die Facebook-Like-Schaltfläche an beliebiger Stelle auf deiner Website einzufügen.

Das war’s schon! Sie können jetzt Ihre Website besuchen und die Gefällt mir-Schaltfläche auf jedem Beitrag sehen.

Facebook like button preview

Methode 2: Manuelles Hinzufügen des Facebook-Like-Buttons in WordPress

Eine weitere Möglichkeit, eine Facebook-Like-Schaltfläche hinzuzufügen, ist die Verwendung von benutzerdefiniertem Code. Bei dieser Methode müssen Sie den Code jedoch direkt in WordPress einfügen, weshalb wir diese Methode nur Personen empfehlen, die mit der Bearbeitung von Code vertraut sind.

Zu diesem Zweck werden wir das kostenlose WPCode-Plugin verwenden, mit dem jeder auf einfache Weise Code zu seinem WordPress-Blog hinzufügen kann.

Zuerst müssen Sie die Seite „Like Button“ auf der Meta for Developers-Website besuchen und nach unten zum Abschnitt „Like Button Configurator“ scrollen.

Get code from Facebook developer site

Als Nächstes können Sie die URL Ihrer Facebook-Seite in das Feld „URL to Like“ eingeben. Dies ist die Seite, die Sie mit der Facebook-Like-Schaltfläche verbinden möchten.

Danach wählen Sie in der Konfiguration einfach das Layout und die Größe des Like-Buttons aus. Sie sehen auch eine Vorschau des Like-Buttons.

Wenn Sie mit der Vorschau zufrieden sind, klicken Sie auf die Schaltfläche „Code abrufen“.

Daraufhin öffnet sich ein Popup-Fenster, in dem Sie unter der Registerkarte „JavaScript SDK“ zwei Codeschnipsel sehen.

Copy the SDK code

Bitte beachten Sie, dass Ihre Website beschädigt werden kann, wenn Sie diese Codeschnipsel direkt zu Ihrem WordPress-Theme hinzufügen. Außerdem werden die Code-Snippets überschrieben, wenn Sie das Theme aktualisieren.

Eine einfachere Möglichkeit, Code hinzuzufügen, ist das WPCode-Plugin. Damit können Sie Codeschnipsel auf Ihrer Website einfügen und benutzerdefinierten Code einfach verwalten, ohne die Themadateien bearbeiten zu müssen.

Zunächst müssen Sie das kostenlose WPCode-Plugin installieren und aktivieren. Weitere Einzelheiten finden Sie in unserer Anleitung zur Installation eines WordPress-Plugins.

Nach der Aktivierung können Sie in Ihrem WordPress-Dashboard zu Code Snippets “ Header und Footer gehen. Kopieren Sie nun den ersten Code-Schnipsel und fügen Sie ihn in die Datei header.php Ihres WordPress-Themes direkt nach dem <body>-Tag ein.

Kopieren Sie einfach den Code und geben Sie ihn in das Feld „Body“ ein. Vergessen Sie nicht, auf die Schaltfläche „Änderungen speichern“ zu klicken.

Add first code to header section

Als Nächstes müssen Sie den zweiten Teil des Codes kopieren und in Ihre WordPress-Website einfügen, um den Like-Button anzuzeigen.

Um zu beginnen, können Sie in Ihrem WordPress-Administrationsbereich zu Code Snippets “ + Snippet hinzufügen “ gehen oder auf die Schaltfläche „Neu hinzufügen“ klicken.

Click 'Add New Snippet' in WPCode

Auf dem nächsten Bildschirm können Sie mit WPCode ein Snippet aus der vorgefertigten Bibliothek auswählen oder einen neuen benutzerdefinierten Code hinzufügen.

Wählen Sie die Option „Eigenen Code hinzufügen (neues Snippet)“ und klicken Sie auf die Schaltfläche „Snippet verwenden“.

Add custom code in WPCode

Danach können Sie einen Namen für Ihren benutzerdefinierten Code vergeben und das zweite Codeschnipsel unter dem Abschnitt „Codevorschau“ eingeben.

Klicken Sie auf das Dropdown-Menü „Codetyp“ und wählen Sie „HTML Snippet“ als Codetyp.

Enter second code and select code type

Als Nächstes können Sie zum Abschnitt „Einfügen“ scrollen und auswählen, wo die Facebook-Like-Schaltfläche erscheinen soll. Nehmen wir zum Beispiel an, dass er vor dem Inhalt erscheinen soll.

Klicken Sie einfach auf das Dropdown-Menü „Standort“ und wählen Sie die Option “ Vor dem Inhalt einfügen “ unter „Seite“, „Beitrag“, „Benutzerdefinierte Beitragstypen“.

Select location of like button

Sobald Sie fertig sind, können Sie auf die Schaltfläche „Snippet speichern“ klicken.

Sie müssen auch auf den Kippschalter klicken und ihn von Inaktiv auf Aktiv umschalten.

Save and activate code snippet WPCode

Das war’s. Nach der Eingabe des Codes wird auf Ihrer Website eine Facebook-Like-Schaltfläche angezeigt.

Was sind Open Graph Metadaten und wie fügt man sie zu WordPress hinzu?

Bei Open Graph handelt es sich um Metadaten, mit deren Hilfe Facebook Informationen über eine Seite oder einen Beitrag auf Ihrer WordPress-Website sammeln kann. Diese Daten umfassen ein Miniaturbild, den Titel des Beitrags/der Seite, die Beschreibung und den Autor.

Facebook ist recht intelligent, wenn es darum geht, die Titel- und Beschreibungsfelder abzurufen. Wenn Ihr Beitrag jedoch mehr als ein Bild enthält, kann es vorkommen, dass beim Teilen ein falsches Vorschaubild angezeigt wird.

Wenn Sie bereits das All in One SEO (AIOSEO) Plugin verwenden, können Sie dies ganz einfach beheben, indem Sie All in One SEO “ Soziale Netzwerke besuchen und auf die Registerkarte Facebook klicken.

Klicken Sie anschließend auf die Schaltfläche „Bild hochladen oder auswählen“, um ein Standard-Facebook-Bild für den Beitrag festzulegen, wenn Ihr Artikel kein Open-Graph-Bild hat.

Upload default Facebook image

Darüber hinaus können Sie auch ein Open-Graph-Bild für jeden einzelnen Beitrag oder jede Seite konfigurieren.

Wenn Sie einen Beitrag bearbeiten, scrollen Sie im Inhaltseditor nach unten zum Abschnitt AIOSEO-Einstellungen. Wechseln Sie dann zur Registerkarte „Social“ und sehen Sie eine Vorschau auf Ihr Thumbnail.

AIOSEO product social sharing settings

Scrollen Sie nun nach unten zur Option „Bildquelle“, und wählen Sie ein Open-Graph-Bild für Ihren Beitrag aus.

Sie können z. B. das vorgestellte Bild, das angehängte Bild, das erste Bild im Inhalt auswählen oder ein benutzerdefiniertes Bild hochladen, das als Open-Graph-Miniaturbild verwendet werden soll.

Image source for open graph

Weitere Details und alternative Möglichkeiten zum Hinzufügen von Open-Graph-Metadaten finden Sie in unserem Leitfaden zum Hinzufügen von Facebook Open-Graph-Metadaten in WordPress.

Wir hoffen, dass dieser Artikel Ihnen geholfen hat, zu erfahren, wie Sie die Facebook-Like-Schaltfläche in WordPress hinzufügen können. Vielleicht interessiert Sie auch unsere Liste, wie man einen Domainnamen registriert und die besten Social Media Plugins für WordPress.

Wenn Ihnen dieser Artikel gefallen hat, dann abonnieren Sie bitte unseren YouTube-Kanal für WordPress-Videotutorials. Sie können uns auch auf Twitter und Facebook finden.

Offenlegung: Unsere Inhalte werden von unseren Lesern unterstützt. Das bedeutet, dass wir möglicherweise eine Provision verdienen, wenn Sie auf einige unserer Links klicken. Mehr dazu erfahren Sie unter Wie WPBeginner finanziert wird , warum das wichtig ist und wie Sie uns unterstützen können. Hier finden Sie unseren redaktionellen Prozess .

Das ultimative WordPress Toolkit

Erhalte KOSTENLOSEN Zugang zu unserem Toolkit - eine Sammlung von WordPress-bezogenen Produkten und Ressourcen, die jeder Profi haben sollte!

Reader Interactions

177 KommentareEine Antwort hinterlassen

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. wpbeginner says

    @artist74 There is no EXACT point because it varies. The exact point is determined by where you want the code to show (for example before post / after the post / within the post etc). Once you decide that then you can also do further styling via CSS!

  3. Ovidiu says

    any words of advice about the XFBML version? I copied the code straight from the facebook developer page, need to know if there is anything to do?

  4. Redefining says

    I have a wordpress.com. I have no idea where to start with adding the Facebook Like button. I have been trying to find the single.pnp option. I just need a start on where to find it as I tried the Appearance and then go to theme and then what?Please can you advise?

  5. Aaron Grey says

    I’m torn between adding the facebook like button at the top of my posts or near the bottom, so I added it in both places. Does anyone know if this can cause issues to have 2 like buttons on one post?

  6. Dimitris says

    Hi, I placed the code in the single.php file and inside the loop as you have instructed. When I Like the post everything works correctly except from the title of the post on FB’s wall.

    For example on MyWebiste.com I like the post with a title MyPost.

    On FB wall shows that someone „likes MyWebiste on MyWebiste.com“, not „MyPost on MyWebiste.com“

    However, the link of „MyWebsite“ links correctly to the respective article, „MyPost“.

    For me that means that the code works just fine and retrieves the right article, but not the title of the article and I’m trying to figure out if I need to do something else in order to show the title of the posts on FB wall and not only their right links.

    Any suggestions would be appreciated.
    Thank you.

    • Editorial Staff says

      That’s weird because it should take your page title. But to override an fix this issue, look at the resource link that we have in this article. You will need to add og:title meta tag.

      Admin

  7. Aaron Torng says

    Thanks for the guide! I successfully added the ‚like‘ button to my individual pages but I’m still having problems adding it to my main site which aggregates all the posts. Do you know which page I’m supposed to add it to and where?

    Thanks again,
    Aaron

  8. Sipovics says

    Hy!

    My problem is that if I „Like“ a post on my site (which is named kukkold.hu) the facebook shows on my profile page that I like the kukkold.hu link on the site kukkold.hu. I experience this at every post, so I always like the main page of my site instead of the link and name of the post. What can be the problem? I tried varius like plugins, and I have inserted the code directly into the loop, but the problem is always the same and it’s really annoying. For a test I wrote a specific permalink into the space of the ID)); ?> block, but the problem was the same again.
    The like counter goes well, so it knows which post how many times was liked.
    What should I do? Please help me!

    Thank you!

  9. charle says

    im using wordpress.com and i trying to add the facebook like box in my blog but i doesn’t work. i read some forum that saying wordpress.com cant read iframe code. is that true? any solution?

  10. Joe says

    I added the code in the loop as you sayed…but nothing happens!! I tried more and more times, in different parts of the loop…. it just doesn’t work!! Any suggestion? Thanks

  11. drowan says

    This is great, however I am encountering a glitch. The code functions fine and everything, but when I like it, instead of ‚liking‘ the specific post, it instead ‚likes‘ the parent home page. The same shows up on the Facebook feed, just the home page. Have you encountered this problem, and what can I do to fix?

    Thanks!

  12. wilson keenan says

    Thanks so much for this.

    I was wondering – are you using this iframe (in the single.php) w/ meta tags in header.php?

    I’m wondering if the URL in the facebook meta tags is conflicting with my ability to use the edited like button you have here?

    Thanks so much,

    Wil

  13. Aurora says

    Thanks for this great resource! I had played around with some plugins but they just weren’t working well for me, then I found your tutorial and just edited the code and VOILA! Success!

    Thanks!

  14. sanjaperic says

    Hi!

    Thanks for this code, but something not working well…
    For example, if I go on post, I see „Like button and Be the first…message“ Ok. Fine! No one like ‚till now, doesn’t matter, I will be the first.. so click, Like! And then! Wow! I see that 178 people acctualy like this, but I couldn’t see that untill I like it first. Do you understand? My english is not so good, but hope you can understand what I am talking about…

    If you find a time to go on my page, and then on any single post, you will see Like button and message Be the first… but if you like it, than you’ll find out, that you weren’t the first! :)

  15. Huw Rowlands says

    Hi,

    I have the like button appearing, but when clicking nothing at all happens??

    Please can you advise on this…
    I even installed the Facebook ‚Like‘ plugin and had exact same issue.

    Thanks

      • Eli says

        Ok! Forget it! Since IE jumps every time I paste something, I must have doubled „the-content“ part somehow.

        Replaced the old single.php, pasted again your code (both before and after „the-content“ and works great either way!

        A million thanks for the code!

  16. agon says

    thank you very much, i am starting to learn wordpress…and here i found your site very helpfull for begginers…keep it up…

  17. Lindsay says

    Is there a way to show on the sidebar which posts have the most likes on Facebook. I think it would be neat to see which ones are shared most often.

  18. Mark says

    I addedd the button to my code and it appears in my blog posts. however when I poke it, my facebook profile does not reflect that I like it? Am I doing something wrong? I should see that I like it my feed, am I correct?

  19. Que says

    I have added the code on single.php , but the button doesn’t appear on all my post.
    If I add the code on every post (from HTML tab), the button appear but encountered problem.
    Why this happen? Is it depend on the theme?

    • Editorial Staff says

      It will appear on all single post pages. If you mean that you want to show it on all pages in your category pages or your index pages, then you would need to paste the code in your index.php inside the post loop.

      Admin

      • Que says

        No, I mean doesn’t show in my posts not pages. Or maybe I placed in wrong part of single.php. Is it possible to paste the code in any part of single.php?
        Thanks.

  20. Andrea says

    This is probably a stupid question, but are the instructions you gave relative to the small „thumbs-up“ graphic and text (showing 184 people liked this. Be the first of your friends) at the top of this post? Or are they for the larger square graphic appearing to the left of your post (the one appearing underneath your tweetmeme button that says 45 shares).

    I’d like to just have that larger square graphic on my blog and have it appear next to my tweetmeme button and I’m wondering how to go about that? Is there a tutorial you can direct me to?

    Thank you so much for any guidance!

  21. Jan Weiss says

    I added the code however if you go to the individual post it gets apage that only shows the facebook „like“ button and does not take the viewer to the actual post. So now if a viewer goes to the post they lose it. Any suggestions?

  22. Ciociaria says

    Hi to everyone,

    I see more blogs use only the button and the number of persons who like without the phrase „be the first….“

    how is it possible?

    thanks

  23. Mike says

    I have noticed many sites have added the button to the top of the page. But isn’t it a better idea to place the button at the bottom of the page, allowing readers to click without scrolling up after they have finished reading the article ?

      • Stu says

        Re: Atahaulpa – I had the same issue as Heather. Solution: In Dashboard, go to Appearance – Atahaulpa Theme Options – Style and edit center column. Paste it in „The LOOP“ section. Works like a treat!

  24. Stu says

    Been noticing this Facebook like button appearing on more and more sites lately and think it’s a great idea. Time to see if I can implement this now… WITHOUT completely destroying my blog (you’d be surprised how close I’ve come multiple times once I start messing with the code – programmer FAIL).

  25. Amanda says

    Love the article but I have encountered some problems. I don’t know where to find the single.php file? lol. Could you guide me? I use wordpress.com and I’m not sure if that makes a difference.

    Thanks!

Eine Antwort hinterlassen

Danke, dass du einen Kommentar hinterlassen möchtest. Bitte beachte, dass alle Kommentare nach unseren kommentarpolitik moderiert werden und deine E-Mail-Adresse NICHT veröffentlicht wird. Bitte verwende KEINE Schlüsselwörter im Namensfeld. Lass uns ein persönliches und sinnvolles Gespräch führen.