I’ve got this code snippet that replaces specific words in the_content() with links:

function link_words( $text ) {

$replace = array(
'google' => '<a href="http://www.google.com">google</a>',
'computer' => '<a href="http://www.computer.com">computer</a>',
'keyboard' => '<a href="http://www.keyboard.com">keyboard</a>'
);

$text = str_replace( array_keys($replace), $replace, $text );
return $text;
}

add_filter( 'the_content', 'link_words' );

I want to use get_the_tags() as the $replace array so it replaces specific tag words with links to their tag archive.

Read more here: WordPress Replace Tag Words in Content with Links


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: