Blog for web designers

WordPress custom social share

Sharing articles and post is a very good feature to promote our articles. There are lots of plugin that can perform this task. But using plugin is not always a good option especially when the whole plugin work can be done by couple lines of code. Below code will perform to share your existing page, article or post to specific social media.

Go to your theme folder
The path to your theme can be:

Just copy the code and paste it into you page.
post share code
Best files to keep the code.

  • single.php
  • header.php
  • page.php
  • footer.php


<div class="post-share">

<a target="_blank" href="<?php the_permalink(); ?>"><span class="share-box"><i class="fa fa-facebook"></i></span></a>
<a target="_blank" href="<?php the_title(); ?>%20-%20<?php the_permalink(); ?>"><span class="share-box"><i class="fa fa-twitter"></i></span></a>
<a target="_blank" href="<?php the_permalink(); ?>&media=<?php echo $pin_image; ?>&description=<?php the_title(); ?>"><span class="share-box"><i class="fa fa-pinterest"></i></span></a>
<a target="_blank" href="<?php the_permalink(); ?>"><span class="share-box"><i class="fa fa-google-plus"></i></span></a>


Santosh Shah

My name is Santosh Shah and blogs at

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.