Social media has gained significant prominence as a source of traffic. If you look at some of the popular blogs out there, you will find that most of them have a LIKE button and a RETWEET button just beside the post excerpt. If you have been wondering how to do that, here is how you can give your visitors an option to share the content from the homepage itself.
To add a Twitter RETWEET button and a Facebook LIKE button beside the WordPress post excerpt on the homepage:
1. Log in to your WordPress Admin Panel
2. Navigate to Appearance >> Editor >> Index.php
3. Search for this piece of code:
<div class=”entry”>
4. Once you find it paste the below given code right under it:
<div align=”right”><div id=’twittley_button’ style=’float:right;margin-left:10px;’> <div id=”fblike”> <script src=”http://connect.facebook.net/en_US/all.js#xfbml=1″></script> <fb:like href=”<?php echo get_permalink($postid); ?>” layout=”box_count” show_faces=”true” font=”"></fb:like></div><br /> <a href=”http://twitter.com/share” class=”twitter-share-button” data-url=”<?php echo get_permalink($postid); ?>” data-text=” <?php the_title(); ?>” data-count=”vertical” data-via=”YourTwitterID”>Tweet</a> <script type=”text/javascript” src=”http://platform.twitter.com/widgets.js”></script> </div></div>
Note: Don’t forget to change the via – “YourTwitterID” to your own twitter username.
Once done, save the file by clicking on the update file button. That’s it. You have successfully integrated the social sharing buttons on the homepage beside each of the post excerpts.