Link post tags words in post content to tag URLs
-
I would like to create link of word(s) in post content (word(s) which is used as post tag of current post) to post tag URL. I created this, and it works, but only for one word (last tag) of post.
$post_content = get_the_content(); // Get post content $search = array($tag->name); $replace = array('<a href="'.get_tag_link($tag->term_id).'" title="'.$tag->name.'" itemprop="url">'.$tag->name.'</a>'); $replacePairs = array_combine($search, $replace); echo strtr($post_content, $replacePairs);
I guess I need tp explode the words to get an array and implode them, than, string replace and replace the matching tags with the warpped url.
How to make it search for all words of tags (of current post) in post content and link that words to it’s tag URLs?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Link post tags words in post content to tag URLs’ is closed to new replies.