Autolink words
-
Is there a function i can insert into my functions.php file to autolink words used anywhere on my site?
The plugin I use (Internal Link Building) does not work with custom post types nor does it change links to words if they are used outside of the content (meta, for example).
I have tried using this:
function replace_infinite_words($content) { $wordlists = Array('word1' => 'https://example.com/1', 'word2' => 'https://example.com/2', 'word3' => 'https://example.com/3', ); foreach($wordlists as $key=>$value) { $content = str_replace($key,'<a href="'.$value.'">'.$key.'</a>',$content); } return $content; } add_filter('the_content','replace_infinite_words');
But, if you try to link a word over one of those words your link used in the WP editor will not work.
Any ideas?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Autolink words’ is closed to new replies.