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

How to Add Facebook Like Button in WordPress

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Do you want to add a Facebook Like button in WordPress?

A Facebook Like button on your WordPress website can make it simple and easy for users to like and share your content. You can increase engagement and get more followers.

In this article, we will show you how to add the Facebook Like button in WordPress.

How to add Facebook like button in WordPress

Why Add a Facebook Like Button in WordPress?

Facebook is one of the most popular social media platforms in the world. Many businesses use Facebook to connect with their customers and promote their products.

Adding a Facebook Like button to your WordPress website can help drive more engagement. It also encourages people to share your content on their Facebook profiles and attract new users to your site.

You can use the Facebook Like button to increase your social followers and build a community. It helps raise awareness about your products and services and boosts conversions.

That said, let’s see how you can add a Facebook Like button in WordPress using a plugin or adding custom code.

Method 1: Add Facebook Like Button in WordPress Using a Plugin

In this method, we will be using a WordPress plugin to add Facebook Like button. This method is very easy and recommended for beginners.

The first thing you need to do is install and activate the BestWebSoft’s Like & Share plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, you can go to Like & Share » Settings from your WordPress admin panel.

Like and share plugin settings

Next, you’ll need to add the Facebook App ID and App Secret. If you don’t have this information, then simply follow the steps below.

How to Create a Facebook App ID and App Secret

Go ahead and click the ‘create a new one’ link under App ID or App Secret field in the Like & Share plugin.

This will take you to the Meta for Developers website. We suggest opening the website in another tab or window because you’ll need to open the Like & Share settings page in your WordPress dashboard to enter the app ID and secret.

From here, you’ll need to select an app type. Go ahead and choose ‘Business’ as the app type and click the ‘Next’ button.

Choose your app type

Next, you’ll need to provide basic information about your app.

You can enter a display name for your app, and be sure that the correct email address appears under the ‘App contact email’ field. Facebook will automatically pick the email address of the account you’re currently logged in as.

There’s also an option setting to choose a business account. You can leave this on ‘No Business Manager account selected’ and click the ‘Create app’ button.

Enter basic information for app

A popup window will now appear where Facebook will ask you to re-enter your password.

This is for security purposes to stop malicious activity on your account. Go ahead and enter your Facebook account password and click the ‘Submit’ button.

Reenter your Facebook password

After that, you’ll see your app dashboard.

From here, you can head to Settings » Basic from the menu on your left.

Go to basic settings page

On the Basic settings page, you will see the ‘App ID’ and ‘App Secret.’

You can now enter this information in the Like & Share plugin settings in your WordPress dashboard.

Copy the app ID and secret

Finish Up Customizing Your Facebook Like Button

First, copy the ‘App ID’ and head back to the tab or window where you have the Like & Share » Settings page opened. Simply enter the ‘App ID’ in the respective fields.

Now repeat the step by copying the ‘App Secret’ data from Meta for Developers page and pasting it into the Like & Share plugin settings.

Customize your Facebook like button

Once you’ve done that, you can choose whether to show the Facebook Like button along with the Profile URL and Share buttons.

There are also settings to edit the Facebook Like button’s size, its position before or after the content, and alignment.

More customization options

If you have enabled the Profile URL button, then you can scroll down to the ‘Profile URL Button’ section and enter your Facebook username or ID.

When you’re done, don’t forget to save your changes.

Now, the plugin will automatically add a Facebook Like button to your WordPress website and position it based on your settings.

You can also use the [fb_button] shortcode to add the Facebook Like button anywhere on your site.

That’s all! You can now visit your site and see the Like button on each post.

Facebook like button preview

Method 2: Manually Add Facebook Like Button in WordPress

Another way to add a Facebook Like button is by using custom code. However, this method requires you to add the code directly in WordPress so we only recommend it for people who are comfortable editing code.

With that in mind, we are going to use the free WPCode plugin to do so, which makes it simple for anyone to add code to their WordPress blog.

First, you need to visit the ‘Like Button’ page on the Meta for Developers website and scroll down to the ‘Like Button Configurator’ section.

Get code from Facebook developer site

Next, you can enter the URL of your Facebook page in the ‘URL to Like’ field. This will be the page you’d like to connect with the Facebook Like button.

After that, simply use the configuration to choose the Like button layout and size. You will also see a preview of the Like button.

Once satisfied with the preview, click on the ‘Get Code’ button.

This will bring up a popup showing you two pieces of code snippets under the ‘JavaScript SDK’ tab.

Copy the SDK code

Please note that if you directly add these code snippets to your WordPress theme, it may break your website. Plus, the code snippets will be overwritten when you update the theme.

An easier way of adding code to your is by using the WPCode plugin. It lets you paste code snippets to your website and easily manage custom code without having to edit the theme files.

First, you’ll need to install and activate the WPCode free plugin. For more details, please see our guide on how to install a WordPress plugin.

Upon activation, you can head to Code Snippets » Header and Footer from your WordPress dashboard. Now, you’ll need to copy the first code snippet and add it to your WordPress theme’s header.php file right after the <body> tag.

Simply copy the code and enter it in the ‘Body’ section. Don’t forget to click the ‘Save Changes’ button.

Add first code to header section

Next, you need to copy the second piece of code and paste it into your WordPress site to display the Like button.

To start, you can go to Code Snippets » + Add Snippet from your WordPress admin panel or click the ‘Add New’ button.

Click 'Add New Snippet' in WPCode

On the next screen, WPCode will allow you to select a snippet from the pre-built library or add a new custom code.

Go ahead and choose the ‘Add Your Custom Code (New Snippet)’ option and click the ‘Use snippet’ button.

Add custom code in WPCode

After that, you can give a name for your custom code and enter the second code snippet under the ‘Code Preview’ section.

Make sure to click the ‘Code Type’ dropdown menu and select ‘HTML Snippet’ as the code type.

Enter second code and select code type

Next, you can scroll down to the ‘Insertion’ section and select where you’d like the Facebook Like button to appear. For example, let’s say you want it to appear before the content.

Simply click the ‘Location’ dropdown menu and choose the Insert Before Content option under Page, Post, Custom Post Types.

Select location of like button

Once you’re done, you can click the ‘Save Snippet’ button.

You’ll also have to click the toggle and switch it from Inactive to Active.

Save and activate code snippet WPCode

That’s it, a Facebook Like button will appear on your website after entering the code.

What is Open Graph Metadata & How to Add it to WordPress?

Open Graph is metadata that helps Facebook collect information about a page or post on your WordPress site. This data includes a thumbnail image, post/page title, description, and author.

Facebook is quite smart in pulling up the title and description fields. However, if your post has more than one image, then it may sometimes show an incorrect thumbnail when shared.

If you are already using the All in One SEO (AIOSEO) plugin, then this can be easily fixed by visiting All in One SEO » Social Networks and clicking on the Facebook tab.

Next, click the ‘Upload or Select Image’ button to set a default post Facebook image if your article doesn’t have an open graph image.

Upload default Facebook image

Besides that, you can also configure an open graph image for each individual post or page.

When you’re editing a post, just scroll down to the AIOSEO Settings section in the content editor. Next, switch to the ‘Social’ tab and see a preview of your thumbnail.

AIOSEO product social sharing settings

Now scroll down to the ‘Image Source’ option, and you can then choose an open graph image for your post.

For example, you can select the featured image, attached image, the first image in the content, or upload a custom image to be used as an open graph thumbnail.

Image source for open graph

For more details and alternate ways to add open graph metadata, see our guide on how to add Facebook Open Graph metadata in WordPress.

We hope this article helped you learn how to add Facebook Like button in WordPress. You may also want to see our list of how to register a domain name and the best social media plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

177 CommentsLeave a Reply

  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. Earl Jones says

    I’ve added the wp-like-button to my blog pages and configured it according to directions. The like counter goes up, so I know that readers are clicking the button, but where do I find the names of these readers so that I can follow-up with them?

  3. Michel says

    Hi Wp Beginner :)

    Just wanna say thank you for all the great articles!
    They allready have helped me a lot, easy to understand…..Love it!

    Cheers guys, keep on doing like you do :)

  4. Macdonald says

    Hi, all.
    I am using Blog Bank WordPress theme which has nicely built Facebook, Twitter, Google+ and LinkedIn buttons but I cannot seem to make them work as intended (refer to my respective social sites). I would like to know if there is a way to do it.
    Thank you for the continual great work you are doing for us, beginners.

    • WPBeginner Support says

      You would want to reach out to your theme’s support for this issue and they should be able to let you know if it is an error with the theme itself or a method to resolve the issue.


  5. stephen Mgbemena says

    Please admin, I’m using the header and footer plugin on my wordpress blog. I added the code on the footer and it’s showing the like button on the down end of my blog. Please how can I add it so it can show right after every single post. Thanks

  6. soshail akash says

    I am unable to make the plugin work on Archives :( It works perfectly fine on Single Posts.

    Your help would mean a lot

  7. Jonathan says

    You said “You can leave the URL field empty, as we will dynamically fill in the URL in WordPress.”

    I was expecting to article to then say what code to put in in order to dynamically fill the URL.

    Does the URL fill dynamically if we leave the data-href blank, with no further action needed?

  8. Vipin says

    How do I show facebook like counts in the post meta.
    Like this: Posted by Admin in Technology on Date | 2 comments | 5 Likes

  9. Toon says

    So far so good, this works.
    But how can I get rid of that popup window as soon as you hit the button.

  10. Len Vanderlinde says

    Have set up a personal web site (not for profit) rather then a blog using WordPress. Very impressed that I was able to do it with my very limited web knowledge. Would like to add a Facebook like button but your instructions do not work for my home page?
    Thanks Len

  11. suzannah says

    THANK YOU. This worked like a charm. Any ideas how to do this on a page instead of just a post? Thanks!!! This is my new favorite site!

  12. Patrick says


    This tutorial sounds like chinese to me. You use vocabulary which assumes certain knowledge that beginners do not have.
    ” First open your single.php file in your theme’s folder. Then paste the following code inside your post loop:”
    What does that mean?
    I understand that you keep your posts short, but very often they are really too short !

  13. mark says


    question, how do i inline FB like with Google +1 and other buttons, pretty much as you did here?

    Thank you,

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.