Topic: Auto Link 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' => 'http://example.com/1',
'word2' => 'http://example.com/2',
'word3' => 'http://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?