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');
Free Graphics, Icons, Tutorials
Free Graphics Free Christmas Vector Icon Graphics Pack 2017Free Fitness Vector Icons Graphics PackFree Camping Vector Graphics PackFree Summer Graphics PackFree File Icon PackFree Fast Food Vector Graphics
Sharing is caring...
Like & Follow
Share the love, share this page! Facebook Twitter Digg Reddit LinkedIn Pinterest Email
Close [X]
The Web Taylor
1000 Lakeside North Harbour Portsmouth, Hampshire PO6 3EN
02392 123358