Skip to content

Instantly share code, notes, and snippets.

@seoagentur-hamburg
Created February 14, 2014 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seoagentur-hamburg/9001685 to your computer and use it in GitHub Desktop.
Save seoagentur-hamburg/9001685 to your computer and use it in GitHub Desktop.
Verlinkt automatisch alle Twitter-Usernamen im Inhalt und auch im Excerpt, sowie den Kommentaren.<
<?php
function tweetlink($content) {
$tweetlink = 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 $tweetlink;
}
// The content
add_filter('the_content', 'tweetlink');
// Comments
add_filter('comment_text', 'tweetlink');
// Excerpt
add_filter('the_excerpt', 'tweetlink');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment