Social sharing buttons are a great way to promote any content. Adding such buttons to your WordPress blog is a great idea. Your visitors will be able to share your posts or like them using their favorite social network accounts. This way, you can garner even more readers to your website.

The best way to make it easy for your visitors to share your content across social websites is by adding their official sharing widgets in your articles. Adding them in a decent place will ensure that they are used. You can add such widgets on top of your posts or right at the end of articles. You can also make such sharing widgets float in your page.

There are tons of plugins in WordPress that are built primarily for adding Facebook, Twitter, Google Plus, LinkedIn etc. widgets. But, if you want to reduce the number of WordPress add-ons, then you can manually add sharing codes to your articles. It is a simple process. You just have to copy paste some code provided by Facebook/Twitter/Google Plus etc.

Step 1: Generating the Code

For Facebook

<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=348328435295070&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://www.thisfox.com" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>

Since, you’d like your visitors to share the URL of your post, change the value in data-href to

data-href=”<?php the_permalink(); ?>”

So your updated code becomes:

<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=348328435295070&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="<?php the_permalink(); ?>" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>

Note that your appId value will be different. Keep the code in a text file in notepad or your favorite text editor.

For Twitter

Based on your configurations a code is generated, that looks something like this:

<a href="https://twitter.com/share" class="twitter-share-button" data-via="gamesnepal" data-related="gamesnepal">Tweet</a>
 <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

To give your sharing button a tall box with count style add data-count=”vertical” to your code.

So your code becomes:

<a href="https://twitter.com/share" class="twitter-share-button" data-via="gamesnepal" data-related="gamesnepal" data-count="vertical">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

Here is a documentation on additional things that you can configure.

Keep it saved in a text file.

For Google Plus

<!-- Place this tag where you want the +1 button to render. -->
 <div class="g-plusone" data-size="tall"></div>

 

<!-- Place this tag after the last +1 button tag. -->
 <script type="text/javascript">
 (function() {
 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
 po.src = 'https://apis.google.com/js/platform.js';
 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 })();
 </script>

Other Social Networks

You can also add other additional social networks such as LinkedIn or Tumblr. Configuring and generating codes is automated once you input some basic details.

Step 2: Placing the Code

In WordPress, every template has its unique code and you will have to figure out where exactly to place the codes that you generated above. Basically, you will have to browse to your /wp-content/themes/<yourthemename>/ folder and edit the single.php file. Add the social sharing codes that you’ve generated above.

You will want to paste the codes after the following post loop.

while ( have_posts() ) : the_post();

Identify the html tags and place social sharing buttons in the exact location that you want to. Save your file and see how they look in your articles. Modify it, move it around and position them exactly how you want to. This isn’t an easy way but works great if you have some HTML knowledge.

Leave a Reply

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