How to add Twitter tweet button to WordPress blog?

SHARE

When it comes to the list of top social media sites, Twitter definitely figures in the list. Twitter is the 11th most visited site. Everyone today uses Twitter today to tweet about what they are doing. Twitter is the easiest way to tweet about your posts and make them go viral. Every blog today has the Twitter tweet button to quick spread their posts around. In this post we will see how we can add Twitter tweet button to your WordPress blog.

How to add Twitter tweet button

In my previous post, I showed how you can add Google +1 button and Facebook Like button to your blog. Continuing on the same effort, we will now add Twitter tweet button to the social share strip so that all the social media buttons are at the same place.

To add Twitter tweet button, do the following steps.

  • Go to the Twitters button page.
  • Select the Share a link button.
  • Check the Show count checkbox.
  • Enter your Twitter username in the Via and Recommend text boxes
  • Finally copy the HTML code.

The code snippet will have two parts, a HTML part consisting of an anchor tag(<a>) snippet and a JavaScript code.


<!-- Anchor tag. Place this code where you want the Twitter tweet button to be shown -->
<a href="https://twitter.com/share" data-via="1UpBlogger" data-related="1UpBlogger">Tweet</a>

<!-- JavaScript code. Place this code just before the closing body tag -->
<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>

Copy the JavaScript code and paste it just before the closing body tag in the footer.php file in your child theme

Add twitter tweet button to WordPress folder.

Copy and paste the HTML code (<a>) in the content.php file in your child theme folder. This code should be in the social share bar div that we created in my Add Google +1 button post earlier. See the below image to understand the correct placement,

Add twitter tweet button to WordPress - place code

Verify your post to see if the Twitter tweet button is visible as shown below,

Add twitter tweet button to WordPress - Social media buttons

Congratulations, you should now have the Twitter tweet button on your posts.

If you liked this tutorial, go ahead and tweet about this by using the above tweet button.

Have you added the Twitter tweet button to your site? How much referral traffic do you get from Twitter? Do let me know through the comments section.

 

2 thoughts on “How to add Twitter tweet button to WordPress blog?

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>