I try to add link of tag archive in text that contain tag.
For example:- if i have tag that name "football" and in single.php i display the content like "the_content();", So now when article have word like " football " it must be add link to get me all article have word " football ".
I do this function, but i need the the link of tag archive ???
function tag_content_replace($post_content) {
global $wp_query, $post;
if (!is_single() ) return $post_content;
$content_with_tags_link = $post_content;
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
$tag_name = ' '.$tag->name.' ';
$link_ = ' <a href="'.get_permalink(get_the_ID()).'" title="'.$tag->name.'">'.$tag->name.'</a> ';
$content_with_tags_link = str_replace($tag_name , $link_ ,$content_with_tags_link) ;
}
}
$content_with_tags_link = preg_replace('/<img.*src="(.*?)".*\/>/', '<a href="'.get_permalink(get_the_ID()).'" title="'.get_the_title(get_the_ID()).'"><img src="\1" alt="'.get_the_title(get_the_ID()).'" title="'.get_the_title(get_the_ID()).'" /></a>', $content_with_tags_link);
return $content_with_tags_link;
}