Facebook Like for WordPress

Facebook like for WordPressToday I’ll show you an easy way to add a Facebook like button inside your WordPress posts.

I’m going to create a WordPress shortcode that will allow you to enter the  simple code nttfblike between brackets to paste a like button any where in your posts.

First you need to get your code from here Facebook Like Button. You can define how you want your personal like button to look by defining :


  • The URL assigned to the like button (Can include non-Facebook Pages)
  • Can the user send the link
  • Layout / Width / Color
  • Whether to display other people that like it
Then click get code.

Add Facebook Like for WordPress

Now jump into your WordPress Dashboard and click on Editor under Appearance in your left sidebar.
Under Templates in your right sidebar, look for the file named functions.php and click it.
At the end of that file paste in the following code except replace the code that lies between quotes after the return statement with your Facebook code.


function nttfacebooklike() {

// Put your Facebook code between the quotes that follow return
return '<script>(function(d){var js, id = \'facebook-jssdk\'; if (d.getElementById(id)) {return;}js = 
d.createElement(\'script\'); js.id = id; js.async = true;js.src = 
}(document));</script><div class="fb-like" data-href="http://www.facebook.com/newthinktank" data-
send="true" data-layout="button_count" data-width="200" data-show-faces="false"></div>';


add_shortcode('nttfblike', 'nttfacebooklike');

That’s it! Now when you put nttfblike between brackets [ ] anywhere, you’ll see the following.
Till Next Time

Leave a Reply

Your email address will not be published.