Friday 30 March 2018

Two Options for Replacing text throughout a WordPress Website, by Jim Walker


We’ve all had web design situations where we’ve needed to replace a snippet of text throughout our website. The task of learning how to replace text is a literal right of passage for most new WordPress designers. And I use the term “right of passage” in regard to Googling the term, “how to replace text within WordPress.” In running that search, you’ll likely find yourself going down so many knowledge rabbit holes that you may forget what you were searching for in the first place. Been there!
Nowadays, I use the uber awesome plugin, Better Search Replace. I mean it simply does the job so elegantly I sometimes forget there were alternatives.
Back in the day, before search and replace plugins were a thing, I recall using a simple bit of text that was all the rage back in 2013. I was a big fan of The Web Taylor Hampshire blog back then and recall geeking out on his blog on numerous occasions. One of the blog posts discussed WordPress: Replace string in content of all pages, gave the following functions.php ready snippet:
function replace_content($content)
{
$content = str_replace(‘##Replace Me##’, ‘##With Something Else##’,$content);
return $content;
Source: https://managewp.org/articles/17293/two-options-for-replacing-text-throughout-a-wordpress-website-by-jim-walker



source https://williechiu40.wordpress.com/2018/03/30/two-options-for-replacing-text-throughout-a-wordpress-website-by-jim-walker/

No comments:

Post a Comment