Return to Snippet

Revision: 63347
at April 29, 2013 11:45 by ederwp


Initial Code
/* Automatically link Twitter usernames in WordPress*/

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');

Initial URL

                                

Initial Description
Automatically link Twitter usernames in WordPress - Paste the code into the functions.php of your theme

Initial Title
Automatically link Twitter usernames in WordPress

Initial Tags
wordpress, twitter

Initial Language
PHP