How to add facebook like button on wordpress


2 Ways to Add Facebook Like Button in WordPress: Step-by-Step

WordPress Basics

Nov 10, 2022

Tomas A.

3min Read

Searching for a way to attract more traffic to your WordPress website? Why don’t you use Facebook Like buttons? With a click, your visitors can like and share your content on their Facebook accounts.

In this article, we will provide you with a comprehensive tutorial on how to Facebook Like button to your WordPress site.

Download Ultimate WordPress Cheat Sheet

Why Do You Need Facebook Like Button on Your Site?

You can’t deny the power that Facebook holds – it has 2.9 billion monthly active users, and over ten million businesses choose to advertise themselves on this platform.

However, you don’t have to use ads to promote your business on Facebook.

Expand your audience reach by using Facebook Like button. Thanks to the platform’s Open Graph, your site’s link will be posted on the visitors’ news feed when the button is clicked. It’s an easy way to get people to share your website.

How to Add Facebook Like Button?

There are two methods you can use to add a Facebook Like button to your website – inserting code to your theme’s template files or utilizing a WordPress plugin.

Manually Adding the Code

Here are the steps to manually insert the button to your site:

  1. Access Facebook for Developers page and click Like Button Configurator.
  1. Fill out the URL to Like field with your site’s link or the URL of your Facebook page.
  2. Adjust the settings – width, layout, and size – to fit your preferences. You’ll see how the button looks like inside the preview window.
  3. Click Get Code, and a popup box will appear.
  1. Copy the first code snippet from the JavaScript SDK tab.
  2. Open your WordPress dashboard and head over to Appearance -> Theme Editor.
  3. Select the header.php file under the Theme Files, and paste the code below the <body> tag. Click Update File.
  1. Go back to the JavaScript SDK tab and copy the second code snippet.
  2. Navigate to Theme Editor again, and select one of the theme files where you want to display the button. For instance, you can choose single.php, page.php, and footer.php.
  3. Click Update File and check your website to see the changes.

Using a Plugin

Another way to add Facebook Like button to your site is by using a WordPress plugin.

There are plenty of plugins available, but we recommend using WP Like Button. It is compatible with all the best WordPress themes, provides four different responsive button layouts, and can display a Share button along with the Like button.

Here is how you use the plugin:

  1. Once you have installed and activated the plugin, open your WordPress dashboard and select WP Like Button menu.
  2. Use “Where to display?” setting to choose where you want the button to be displayed.
  1. If you do not want to show the button on particular pages, select the Exclude specific pages and posts. A dropdown menu will appear where you can pick the posts you want to exclude.
  2. Scroll down to the Preview section to customize the looks of your button.
  3. Hit Save Settings — and you’re done.

Alternatively, the plugin also allows you to manually add the button by inserting the [fblike] shortcode to your WordPress editor.

If you want to disable the Like button, simply switch the On/Off toggle located at the bottom of the settings page.

Conclusion

All in all, Facebook Like button is an important tool to boost your website traffic. The more readers like and share your content, the bigger the possibility that your website will thrive.

In this tutorial, you’ve learned two methods to add Like buttons to your site. The first one requires you to get a certain code from Facebook for Developers, while the other needs you to use a plugin.

Which method do you prefer? Let’s discuss it in the comment section below.

Learn What Else You Can Do With WordPress

How to Login to WordPress
How to Duplicate Pages and Posts on WordPress
How to Delete WordPress
How to Use WordPress Importer
WordPress Taxonomy Guide
Guide to WordPress Revisions
How to Add Related Posts in WordPress

Tomas is a senior customer support agent at Hostinger. Besides providing top-notch technical advice on a daily basis, he likes to create websites and do various coding side projects.

More from Tomas A.

How to Add Facebook Like Button in WordPress (UPDATED)

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.

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.

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.

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.

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.

After that, you’ll see your app dashboard.

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

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Facebook Integration - Support

This guide shows you how to integrate Facebook features into your site, including posting to Facebook, allowing visitors to share your content, embedding a Facebook page on your site, and more.

Content

  1. Posting to Facebook
  2. Share Button for Facebook
  3. Widget for Facebook Page
  4. Facebook Pixel
  5. Facebook Embedded Objects
  6. Commenting with Facebook Accounts
  7. Troubleshooting
Posting to Facebook

Posting your blog posts to Facebook is a great way to increase your blog traffic and bring friends and family to your site. You can connect a Facebook page to your site to post posts directly to it.

Setting up the "Publish" function on Facebook

↑ Contents ↑

Share button for Facebook

You can add a share button for Facebook (and choose other ways to share posts, including Twitter, Google or Pinterest) in Tools → Marketing → Share buttons on the console site.

To add a button to the blog, enable the posting methods you want, click Edit Share Buttons and select Facebook.

Setting the Share function

↑ Contents ↑

Facebook Page Widget

If you have a Facebook Page and are using widget-enabled themes, you can add the Facebook Page Plugin to your sidebar or other widget area. To do this, simply add the Facebook page plugin in the section Appearance → Customize → Widgets on the site console.

The page must be public and must not have any age or geographic restrictions so that all users can see it, as in the screenshot below:

This is how it will look on the website:

↑ Contents ↑

Facebook Pixel

The Facebook Pixel provides a code that can be integrated into the website. It looks like this:

The full code will only work on a site with a WordPress.com Business or eCommerce plan, or a legacy Pro plan with plugins installed. If your site has a free plan, or Personal or Premium plans activated, the tags and will not work. Instead, copy only the part that is inside the code part:

Sites that use widget areas

Using a widget-enabled theme allows you to add code to the Custom HTML widget to install a pixel on your site. Make sure the widget is assigned to a widget area that appears on all pages. Usually the widget area Footer is displayed on all pages, so your Facebook pixel will work there too.

Sites using the site editor

Using a site editor enabled theme allows you to add code to the Custom HTML block in the theme title.

Note that once added, the Facebook pixel takes about 20 minutes to update its status on the Facebook console.

📌

Please note that the pixel check steps above will not work with Facebook's Event Setup Tool, Auto Events and Auto Adv Matching. If you want to use these features, you'll need to upgrade to a plugin-enabled plan, install any plugin, and then use the full Facebook pixel code.

↑ Contents ↑

Embedded Facebook Objects

You can also add any post from the public Facebook timeline to a post or page. We have a complete guide to implementing Facebook posts.

↑ Contents ↑

In all WordPress.com blogs, Facebook users can log into their account and leave a comment. Thanks to the features of our system, it is very easy for Facebook users to leave comments on blogs.

↑ Contents ↑

Troubleshooting

Browser extensions and security add-ons such as Facebook Disconnect may interfere with these features. They may need to be disabled.

Variety of tariff plans and price offers

  • Free

    Ideal for students

  • Personal

    The best option for presenting your hobby

  • Premium

    Best option for freelancers

  • Business

    Ideal for small businesses

Your rating:

Like and share facebook button on wordpress site — info-effect.

ru

Hello everyone!

Ilya Zhuravlev is in touch! and today I would like to tell you how to install a facebook like button on a wordpress site. What it is ? Your visitors will be able to like you, that is, they like it, but that's not all, you can also share the post on your facebook page if you wish. Such a feature can certainly be very useful for your site. The like and share button will make your site more attractive and visited!

Plugin features:

Simple settings, without codes, ID, App, etc.

- Ability to select where buttons, posts, pages, home will be displayed.

- The display of the button on mobile devices can be disabled.

- Button location , before or after content.

- Alignment, Left, Right, Center.

- Buttons in Russian , a large selection of languages.

- Select theme for buttons.

- You can turn off the Share button and leave it as Like.

You can add buttons to the site using the plugin - WP Like button . The plugin is very simple and easy to customize. You can install this plugin directly from the WordPress admin panel. Go to the tab: Plugins - Add new, enter the name of the plugin in the search form, press Enter, install and activate the plugin that opens.

To configure the plugin, go to the tab: WP like button.

Let's analyze the settings:

Where to display, select where to display the buttons.

- Homepage, Homepage.

- All pages, all pages.

- All posts, all posts.

- Exclude the following pages and posts, if you check the box, you can exclude some pages and records.

- Enable like button for mobile (Responsive layouts), if select Yes, the buttons will be displayed on mobile.

- Shortcode, you can use a shortcode to insert buttons in a specific place on your site.

- Code Snippet, you can use php code to insert buttons in footer.php or header.php files

- Choose where buttons will be displayed by default. Before - before the content, After - after the content.

What to like

- Each page/post will have its own like button, each page and post will have its own like button. It is recommended to select this option.

- Entire Site, the button will be for the entire site, that is, if +1 like is put on one page, then the same will be +1 on others.

- You can set your own URL for the button to be shared on facebook.

- Language, select the language for the button.


Learn more