Long time back I’ve posted an article on “Power of @anywhere” but @Anywhere
was deprecated and ceased on March 5th, 2013. Are you a power Twitter user? Does your commenter uses their twitter name to comment on your WordPress blog? Now with below simple code you can easily link any Twitter username to Twitter Profile Link.
Other must read:
- Genesis Framework Tips: Show Your Custom Shortlink on Single Page
- WordPress Tips: How to List all Posts that contain a Particular Custom Field and More
- Cool Mouse Hover Social Media Buttons for WordPress Blog
Just add below code to functions.php file.
function getTwitterLink($content) { $getTwitterLink = 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 $getTwitterLink; } add_filter('the_content', 'getTwitterLink'); add_filter('comment_text', 'getTwitterLink');
Usernames have to be written under the form @username.