In response to the previous question, I want to replace each instance of the word ALL-CAPS * with a link in the following format:
dictionary.com/browse/<TERM>
I use the preg_replace call:
$content = preg_replace('#[AZ][AZ]+#', '<a href="//dictionary.com/browse/$1">$1</a>', $content);
Using http://gskinner.com/RegExr , it looks like I have the correct regular expression and that it should be replaced with every find.
Did I do something wrong both in the preg_replace call and in the process of registering the plugin / filter in the Wordpress API?
Full call context:
function define_filter($content){ $content = preg_replace('#[AZ][AZ]+#', '<a href="//dictionary.com/browse/$1">$1</a>', $content); } add_filter('the_content', 'define_filter');
* I use the syntax [AZ][AZ]+ to make sure that I do not match words like "I" and "A"
source share