Skip to content

How to Add Social Sharing Buttons to a List of WordPress Posts on an Index Page or category page with No Plugins

Facebook Like Buttons for WordPress Loops

  1. Go to the official Facebook page for creating buttons.
  2. 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.
  3. Click Get the Code and choose IFRAME as the type of code you want to use.
  4. Copy and paste the providing code into your theme where you want the button to appear.
  5. 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>
  6. 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.

 

Full article:

http://clicknathan.com/web-design/how-to-add-social-sharing-buttons-to-a-list-of-wordpress-posts-on-an-index-page-with-no-plugins/

 

Published inWordpress