Contact us for a project proposal!

HOW TO: Add Your Twitter Handle to “ShareThis” Plugin Tweets

2 Comments

ShareThis is a great sharing plugin built for WordPress that allows visitors to share your content through their own social media network with only a couple of easy clicks. The only complaints I’ve gotten from clients who use the plugin are:

  1. The buttons are aligned to the left rather than being centered on the line they occupy
  2. When their visitors share a post via Twitter, it doesn’t mention (@) their Twitter ID
Fixing these two quirks are pretty simple. If you don’t care about centering them, just skip to the second part and change the code in the ShareThis plugin settings screen.

Centering the Boxes

Rather than trying to modify the plugin code, you simply set your options and extract the code generated by the plugin to display the boxes. (Click on an image below to expand it to full size)

After following the instructions in the graphic illustrations above, open your theme’s editor (in the WordPress dashboard, go to Appearance –> Editor) then click on Single Post // single.php in the file list in the right side of the page. Find the tag and execute the following either above or below it depending on whether you want the buttons to be displayed above or below your content.

Paste the ShareThis code you copied from the plugin’s settings screen. Add <div style="text-align: center;"> to the beginning and add </div> to the end of it.

Adding {@username} to Twitter Shares

Find the following section in the ShareThis code:

<span class='st_twitter_vcount' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>' displayText='share'></span>

… replace that section with this and be sure to replace YOURusernameHERE with your Twitter ID:

<span class='st_twitter_vcount' st_title='<?php the_title(); ?> {via @YOURusernameHERE}' st_url='<?php the_permalink(); ?>' displayText='share'></span>

That’s it. You’ve got centered boxes and your visitors’ tweets sharing your content will mention you, or your brand’s, Twitter name. If you have any questions or complications, leave me a comment below!

Bonus: Add a share-to-Twitter link anywhere!

Add the following code to any of your theme files:

Using a text link:

<a href="http://twitter.com/home?status=Currently reading @YOURusernameHERE: <?php the_title(); ?> – <?php the_permalink(); ?>" title="Twitter">Share via Twitter!</a>

Using an image link:

<a href="http://twitter.com/home?status=Currently reading @YOURusernameHERE: <?php the_title(); ?> – <?php the_permalink(); ?>" title="Twitter"><img src="IMAGE SOURCE URL HERE"></a>

Posted in: STAFF BLOG

Share this Article:

About

Kat Robertson began designing in 2002 for personal projects before turning her hobby into a home business when she opened Robertson Enterprises, the parent company of the eDesign-Pro subsidiary, in 2004. She is the mother of five children and enjoys blogging at iHeart7.com in her spare time where she shares her experiences in the midst of all the chaos.

2 Comments

  1. Thanks for the helpful advice. i need to know how to do this.

    [Reply]

  2. I could not make the @username adding work. It did not save and never showed up.
    Did I miss something?

    [Reply]

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>