Or, embed this snippet using GenerateWP WordPress Plugin.



Automatically link twitter usernames in posts

Will automatically link twitter usernames in your posts. This snippet will look for text like @wpsnipp and convert it to @wpsnipp something I’m sure many of you will find useful.

function content_twitter_mention($content) {
        return preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/', "[email protected]$2", $content);

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