How to Add a Follow Me on Twitter Link to Your Posts

There are many ways to enhance the way your blog or website looks. A common question we receive here at StudioPress is how to add a follow me on Twitter link posts. This is something that is very easy to accomplish by following the steps below.

Here’s an example of the Follow Me on Twitter link at the end of a post:

Follow Me on Twitter Link

Step #1
You’ll need to establish a class of CSS for the link. Add this to your theme’s stylesheet:

.follow-me {
	background: url(images/twitter.png) no-repeat left center;
	padding: 2px 0px 2px 20px;
	}

You’ll notice that this CSS defines the link class you will use, and that an image is associated with it which is set as a background image. You’ll need to upload an image to your theme’s images directory on your server in order for it to show. Below is a sample image you can use for your Follow Me on Twitter link – you can right click and save image as.

Twitter
Step #2
The next thing you will need to do is open up your theme’s index.php file and look for the content call:

< ?php the_content(__('Read more', 'studiopress'));?>

Immediately after that, place this code:

Make sure you replace “username” in the code above with your own Twitter username. Keep in mind that this tutorial was written for StudioPress “classic” themes – if you want to add a Follow Me on Twitter link to your post, check to see if your theme has a single.php file. If it does, use that file instead of index.php in Step #2.

Comments

  1. Good Article!

  2. Excellent tut. Brian, this is very handy to add a follow me after each post, seeing as different posts can potentially attract different people, depending on their interests.

    Thanks

    de P

  3. Brian this is great! I’ve done this and it shows on my posts, however it’s caused the comments boxes to move up towards the sidebar in FF. Is this happening for anybody else?

  4. Thank you Brain – this is awesome, it works charm, myself and my clients are all love this little script .. Happy New Year 2010 ! :-)

  5. Thanks for this – it works perfectly…brilliant stuff.

  6. This is great advice, Brian. We have added these links to most pages our our site, in addition to our Twitter feeds on some pages. I also plan to retweet this post for you.

  7. Thanks for the tip, works like a charm!

  8. Nice tip – I’ve just launched my first site using a Studiopress theme, and this will come in handy as I spend a lot of time using Twitter and get a fair amount of traffic from it to my existing sites…

  9. Hi,

    thanks for the post. I had this working beautifully until I upgraded to WP 2.9.1 at which point it stopped working. I’ve checked the code and it’s all still in place. Has anyone else had the same problem?

    I can’t figure it out :(

    Thanks,
    Craig.

  10. Brian,
    thanks for the tip
    is there a way to call this code relevant to specific authors? — similar to an author box — this way the twitter link would be specific to that particular author — it would be ideal if we could include / place code within the authorbox
    thanks in advance / steve

  11. errrr how do i use block quotes here so that it will show the php for the user code..errrrrr

  12. Brian,

    Thanks for the info. This was pretty cool. One question. I’m using Apture with auto-enhance existing links and it seems to mess this up a bit. Have you worked with Apture? Do you know how I can modify the script above so it won’t auto-enhance this link?

    Thanks,

    Aaron

  13. Eventhough it is a very easy and quick way for people to retweet, it is limiting the readers only to Twitter versus share this or other methods of social linking. I like this and use it but wonder what others think about this feature. With the “share this” or other methods you let the readers go to digg, delicious, twitter etc. I do not like when bloggers sometimes keep a share this link and have all the possible shareable options in there (like add this) and that confuses or puts off some readers.

    What do others think and have experienced.

    NENM

  14. I am also a Starbucks addict and it is my virtual office where I can meet clients. I found you company (funny enough) from a site that was being sold on Flippa they were using one of your themes. Like your templates.

  15. Nice. Thanks Brian. Also thanks for adding the info on how to do it on non StudioPress sites.

  16. Hey Brian, I am in my Main Index Template (index.php) file and the only code showing is:
    <?php
    /**
    *
    */
    genesis();

    Am I in the wrong file? The Main Index Template is the only one designated with the (index.php).