これもフィルターをひっかける
add_filter('the_content', 'url2href'); function url2href($content) { if ( is_singular() ) { //外部サイト $content = preg_replace("/(https?:\/\/)(?!{$_SERVER["HTTP_HOST"]})([-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/", "<a href=\"\\1\\2\" target=\"_blank\" rel=\"nofollow\">\\1\\2</a>", $content); //自サイト $content = preg_replace("/(https?:\/\/{$_SERVER["HTTP_HOST"]})([-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/", "<a href=\"\\2\">\\1\\2</a>", $content); } return $content; }