How to Add Social Media Buttons to WordPress Post Excerpts

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.

add social media buttons to post excerpts

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=”″></script>

<fb:like href=”<?php echo get_permalink($postid); ?>” layout=”box_count” show_faces=”true” font=”"></fb:like></div><br />

<a href=”” 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=””></script>


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.