WordPress Snippets at WPcustoms

Auto-link twitter usernames

Writing ‘@twitter_username’ will automatically linked to the twitter user profile. Somehow the code adds an extra \” to it sorry – you need to remove that.


/**
 * Snippet Name: Auto-link twitter usernames
 * Snippet URL: http://www.wpcustoms.net/snippets/auto-link-twitter-usernames/
 */
 function twtreplace($content) {
	$twtreplace = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/',"$1@$2",$content);
	return $twtreplace;
}

add_filter('the_content', 'twtreplace');   
add_filter('comment_text', 'twtreplace');