Latest Updates » [1] Auto XML Sitemap [2] Create Contact Page [3] Blogger and Wordpress Templates! Download Now !


Saturday, 6 July 2013

WPSNIPPET:Automatically link twitter name into wordpress posts



Twitter widely used for social networking, social marketing and web promotions. After creating profile at twitter you invite people to follow you. If you have a huge follower base it is difficult to kept all names in mind but today's snippet help you lot.

If you use twitter lot and If you want that your readers know about your followers profile then this simple wordpress snippet help you to link followers name automatically into your blog posts, pages and comments...

With this snippet you can link follower name directly and after click the link you can tweet directly into their profiles.



How to link automatically twitter follower names in post/pages/comments in wordpress.


1. Open your functions.php file and paste following code at the end .

function twtreplace($content) {
$twtreplace = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/',"$1<a href=\"http://twitter.com/$2\" target=\"_blank\" rel=\"nofollow\">@$2</a>",$content);
return $twtreplace;
}
add_filter('the_content', 'twtreplace');  
add_filter('comment_text', 'twtreplace');

2. Once you saved the file all twitter usernames in posts and comments will automatically be linked to their Twitter profiles. Usernames have to be written under the form @username.

Thanks to ederwp (snipplr) this awesome snippet.  Pl consider sharing it with friends.


Kindly Bookmark this Post using your favorite Bookmarking service:
Technorati Digg This Stumble Stumble Facebook Twitter

Advertise Here

2 comments:

  1. Hi, just wanted to tell you, I loved this blog post.
    It was inspiring. Keep on posting!

    Feel free to surf to my homepage ... kotburger

    ReplyDelete


ABOUT THE AUTHOR

Hi! I am K Ajay, currently live in Chandigarh, India. A young Web Designer, Pro Blogger, Graphic Designer & an addicted Web Developer. I love working on Blogger and WordPress using CSS Tricks,and Web Designing. Read More...

FOLLOW US HERE


RANDOM POSTS

Bwidgets4all-Helping Bloggers with Blogging Tricks © 2013. All Rights Reserved | Free Blogger Templates | | Back to Top