Do you have a sentence that occurs multiple times on several posts and wanna change that sentence?
I will show you have to replace all instances of a string in WordPress.
First, you need to access your websites file manager and locate the functions.php folder under:
- wp-content
- themes
- the theme currently in use
- here you should find functions.php
When you have found that, you’ll add the following code
function replace_text($text) {
$text = str_replace('look-for-this-sentence', 'replace-with-this-sentence', $text);
$text = str_replace('look-for-that-sentence', 'replace-with-that-sentence', $text);
return $text;
}
add_filter('the_content', 'replace_text');
So this should be straightforward, you’ll add the sentence you wanna replace in the “look-for-this-sentence’, and what it needs to be replaced for in the “replace-with-that-sentence”.
It’s a good thing to note that nothing is actually changed in the database, it’s only changed when shown to the browser.
Hey I know this is off topic but I was wondering if you knew of any widgets I could add to
my blog that automatically tweet my newest twitter updates.
I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience
with something like this. Please let me know if you run into anything.
I truly enjoy reading your blog and I look forward to your new updates.