As your website grows, sometimes you end up coming across some really bad habits, or have strange characters come up. Sometimes you also may use plugins that produce shortcodes, and then later on need to replace them. Some of those habits or shortcodes can extend across several hundred posts. That means you have to go and edit each one, right?
Not necessarily. In this tutorial, we’re going to cover how to find and replace text in WordPress. I’m going to give both an easy tool for those who don’t want to muck with SQL queries, and also a way to do so directly in the MySQL database.
Please note that before you proceed to find and replace text in WordPress site using any of the methods mentioned below, you should generate a backup of your website.
How to Find and Replace Text In WordPress – With a Plugin
Search and Replace, and Search Regex are both plugins that allow you to find and replace just about anything including from text in WordPress.
Search and Replace
The Search and Replace plugin has a lot of options to choose from in finding and replacing whatever text or strings you want. It’s a matter of simple filling out what you need to find, what you want to replace it with, and selecting where you are replacing it.
Search Regex
The Search Regex form is a lot simpler than Search and Replace. Simply fill the form and select what you’re trying to find and replace.
How to Find and Replace Text In WordPress – Using MySQL database
For those not afraid to open MySQL, you can find and replace text using the following general string. Just replace the areas that are capitalized with the correct info.
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME,'TEXT YOU WANT TO FIND','TEXT YOU WANT TO REPLACE IT WITH')
As an example- Perhaps you kept writing WP instead of WordPress throughout your website’s post content. In order to correct that, alter:
1. TABLE_NAME with wp_posts because that is the correct table for your posts
2. FIELD_NAME with post_content because the post content is where that content you need to replace is at
3. TEXT YOU WANT TO FIND with WP
4. TEXT YOU WANT TO REPLACE IT WITH with WordPress
Your query string in MySQL will look like the following:
update wp_posts set post_content = replace(post_content,'WP','WordPress')
Here’s a screenshot of the query.
Just click on the button that says ‘Go’ and it will perform the query for you.
So, these are just some of the ways you can find and replace text in WordPress. Hope this helps!
Yorinda Wanner says
Hi Nile,
awesome tips.
I appreciate how you shared three ways to do this!
Thanks for sharing your expertise!
Cheers,
Yorinda
Siphosith says
Thank you for sharing this information , makes things easier. You sure know your WordPress stuff.
SAJID says
Yes really agree
Llyane says
Pretty neat trick, thanks so much!
Hasir Nancy says
Hello Nile,
You made my work more easy. Previously I could find words but couldn’t replace it in wordpress. Your article greatly helped me to finish my tasks fast and smoothly.
Thanks and Happy blogging
Nancy
Zach says
I’ve totally done this. We changed our firm name, and we had to replace every instance of the old one with the new one. I had to go figure this out on my own. This tutorial would have been helpful.
Shelley Alexander says
Nile, Thanks for sharing the 3 ways to find and replace text in WordPress. I wish I had read this post a few weeks ago when I had to change some links in a bunch of my posts. I appreciate all the useful information you share on your site!
Arpit Roy says
This certainly makes finding and replacing text easier. Thank You ๐
Akhilesh says
I don’t know how to find and replace the text in my word-press website earlier but your this article. I learned this.
Thanks You … ๐
Peter Pratty says
It’s a really great thing to read such information as this here, this is a big help not just to every new SEO but also to just WordPress bloggers. So thanks for this and hope to see more from you.
Gaurav Heera says
Hello Nile,
Such a great article, thanks for providing this article, actually i am blogger and looking for find and replacement of text, thanks again for providing, i have installed this plugin in one of my website.
warm regards
Gaurav Heera
Mahasin Handal says
Hi..Nile!
Thanks for sharing this quick and helpful tutorial about how to find and replace text in WordPress.
jasimahmmed says
This tutorial would have been helpful for us. thanks
Karen Peltier says
Hello Nile. These are super useful tips for how to search and replace code within WordPress.
One thing right now I know that I could update on my blog would be my copyright dates. I’m sure there are may be other things that need updating as well.
Thanks again for the tips and the plugin suggestions! I’m going to check them out for sure.
Kyle Nelson says
Seems like these plugins can come into some good use on many scenarios. Awhile back I was really needing to use something like this. I am going to dig a bit deeper in these plugins and see which one fits my blog best. Thanks!
Mark says
Thanks for the tutorial Nile!
But this exactly the type of techie stuff that I definitely try
and stay away from!
I prefer for the most part to pay the experts such as yourself to
handle this part of the deal!LOL!
But thanks for taking the time to share it!
David Merrill 101 says
This is a great tip, Nile.
This can really save a lot of time when you need to accomplish a text replacement.
Willena Flewelling says
You write good tutorials, Nile. Thanks for showing 3 ways, because I don’t like fiddling with MySQL. It’s too easy to make a big mistake I can’t fix without help.
sonika dewakar says
thank you for updating this informative blog this blog is really helpful and inmformative blog.
Tanmoy Das says
Sometime simple things can be complicated like this find text and replace. This is a really nice tutorial. Thanks for this nice guide.
Julieanne van Zyl says
This is a great tip Nile, such easy ways to search and replace, especially for a blog with a huge amount of posts.