Twitter I hate this fecking cold. 5 days later and it won't go. #fb 1 week ago


Nov 09
24th

Add Twitter links to your WordPress posts


Want an easier way to add links to Twitter user pages? Here’s a quick solution.

Add the following code to your functions.php file within your theme folder…

add_filter('the_content', 'link_to_twitter');
function link_to_twitter($content) {
    $start=strpos($content,"[@");
    while ($start!=0) {
        $code=substr($content,$start+2,strpos($content,"]",$start)-$start-2);
        $content=str_replace("[@".$code."]",'<a href="http://twitter.com/'.$code.'" target="_blank">@'.$code.'</a>',$content);
        $start=strpos($content,"[@",$end);
    }
    return $content;
}

Now, you simply need to simply specify a Twitter username within square brackets and it will be replaced with the same username, but now with a link to Twitter.

For example, add [@dartiss] to your post and it will display as @dartiss.


Related posts:
  1. Simple Twitter Link – WordPress Plugin “Simple Twitter Link” allows you to add a link to your blog that will send the URL of the page/post to your Twitter status....
  2. Simple Twitter Link – WordPress Plugin updated! A day after its initial release a new version is available! But, don't worry, it's not a bug fix - it adds new functionality, as...

Share with Delicious Share with Digg Share with Facebook Share with LinkedIn Share with MySpace Share with reddit Share with StumbleUpon Share with Twitter

Comments

There are no comments at present.

Pingbacks & Trackbacks

There are no pingbacks or trackbacks at present.

Leave a Comment

All these comments are validated before being placed on the site. I will NOT allow any spam to be shown, I do not follow the links myself and obvious self-promotion of your site is not accepted either.

CAPTCHA Image CAPTCHA Audio
Refresh Image

58 queries in 1.963 seconds.