We recently did a project that whenever the company name was mentioned in a post or a page, the client wanted it to be a specific colour without having to manually set it. This was simple we thought, just replace the string (company name) on all the content of the WordPress site.
And this is how we did it, simply edit the following code to your requirements and paste into your theme’s functions.php file:
function replace_content($content) { $content = str_replace('Company Name', '<span class="company">Company Name</span>',$content); return $content; } add_filter('the_content','replace_content');
But this doesn’t just have to apply to a company name, it can replace any word you want:
function replace_content($content) { $content = str_replace('##Replace Me##', '##With Something Else##',$content); return $content; } add_filter('the_content','replace_content');