Facebook Like Buttons for WordPress Loops
- Go to the official Facebook page for creating buttons.
- For the URL to Like field, just enter in your website’s main URL for now, something like http://yourwebsite.com. You can set any of the other settings as you’d like.
- Click Get the Code and choose IFRAME as the type of code you want to use.
- Copy and paste the providing code into your theme where you want the button to appear.
- Before saving, look through the code for the text “http://%3A%2F%2Fyourwebsite.com”, as highlighted in the example below:
<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fyourwebsite.com&send=false&layout=standard&width=450&show_faces=true&action=like&colorscheme=light&font&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
- Replace that entire highlighted section with <?php the_permalink(); ?>
And tooty fruity oh rudy you’re all set for Facebook. What we did there was used WordPress’
the_permalink() function to set the URL instead of the one Facebook asks us to manually enter.