Managing a WordPress site often involves making changes across many posts and pages. One common task is searching for specific content and replacing it with something new.
We know firsthand how time-consuming it can be to search for and replace content manually. If you aren’t careful, it can also cause mistakes.
That’s why we looked for easier ways to search and replace content on your WordPress site. These methods will allow you to make bulk changes quickly and efficiently.
Let’s examine the reasons why you might need to search and replace WordPress content and how to do it effectively.
When You May Need Search and Replace (Use Cases)
There are many situations where you might need to search and replace content on your WordPress site.
Here are some common use cases:
- Changing URLs: When you move a WordPress site to a new domain or switch to HTTPS, you will need to update all the URLs used across your website to point to the new domain name or the HTTPS URL.
- Updating Old Content: If you have outdated information, then you can quickly update it across multiple posts. For instance, product pricing, stats, and figures, and more.
- Fixing Typos: Sometimes, you will find a repeated typo or error in your content. Using search and replace can fix it all at once.
- Replacing Shortcodes: If you are using a WordPress plugin that uses shortcodes, then switching the plugin could break those shortcodes. A quick search and replace can help you fix that.
- Updating Brand Names or Phrases: When your business rebrands, you can update the brand name across your site with ease. Similarly, if you have mentioned a company many times on your blog and they change their name, you will be able to easily update and use the new brand name.
- Replacing an Image Used Across Multiple Locations: With just a click, you can quickly replace an outdated image anywhere on your site with a new one.
Using a search-and-replace plugin saves time and ensures consistency. Now, let’s prepare for the search-and-replace process by creating a backup.
Preparing for Search and Replace
Before making any changes to your WordPress database, it’s crucial to create a backup. This ensures you can restore your site if anything goes wrong.
We recommend using Duplicator. It is the best WordPress backup plugin for creating on-demand backups, and more importantly, it makes it easy to restore your site using those backups.
Note: A free version of Duplicator is also available. It is limited in features but would be enough to create a database backup and store it on your computer.
For detailed instructions and alternative backup options, see our beginner’s guide on creating WordPress backups.
Having a backup gives you peace of mind and ensures your data is safe. Now, you can safely perform search and replace tasks on your website.
We will cover 2 methods in this tutorial, and you can use the quick links below to jump to the one you want to use:
Method 1: Using Search & Replace Everything (Recommended)
For this method, we will show you how to use the Search & Replace Everything plugin.
Created by the team behind WPCode, which is the best WordPress code snippets plugin, Search & Replace Everything is the easiest way to search and replace content on your WordPress site.
It can be used for all kinds of content, including:
- Text
- Images
- Content within specific database tables
First, you need to install and activate the Search & Replace Everything plugin. If you need help, then please see our tutorial on how to install WordPress plugins.
Note: There is also a free version of Search & Replace Everything. However, it has fewer features, such as not letting you undo changes or view history.
Upon activation, you need to go to the Tools » WP Search & Replace page to start using the plugin.
Searching And Replacing Content
Under the Search & Replace tab, simply enter the content you want to search for and then add the content you want to replace it with.
By default, all searches are case-sensitive. This means if you search for “Wordpress,” it will not match “wordpress,” “WordPress,” or “WORDPRESS.”
If you want your search to match all instances, regardless of case, then you can toggle the “Case Insensitive” switch below.
If you know which database tables to look into, then you can select those down below.
For example, if you want to search and replace some text in your posts, then you may want to select the posts
table. This will make your search faster and more precise.
You can also select multiple tables or all tables. The plugin is optimized for performance, so it will run the search efficiently without slowing down your website.
Bonus Tip 💡: Learn more about WordPress database management and what each table does in WordPress.
Finally, click on the ‘Preview Search & Replace’ button.
The plugin will open a popup in which you will see a preview of items that match your search term and how they would look when replaced with the term you provided.
If everything looks good, then click on the ‘Replace All’ button to apply your changes.
The plugin will then show a warning message reminding you to create a backup.
Since you have already created the backup, you can click on ‘Yes’ to apply your changes.
Track And Undo Changes
If you are using the Pro version of the plugin, then you can easily view past changes you made and undo them if needed.
Switch to the ‘History’ tab on the plugin’s settings page, and you will see a list of your search and replace operations.
Then, simply click the ‘Undo’ button if you want to revert the changes.
Replace Images in WordPress
Search & Replace Everything doesn’t just search and replace text. It can also replace an image.
This can be handy in situations where you have used the same image across multiple posts, pages, and other locations on your website.
Replacing the image using Search & Replace Everything will change the image in all those locations.
Just switch to the ‘Replace Image’ tab under the plugin settings and locate the image you want to change.
Take the mouse over to the image and then click on the ‘Replace’ button.
Next, you will need to upload the image you want to use as the replacement. Click on the ‘Choose a file…’ button to upload.
The plugin will show you a preview of your replacement image next to the old one.
Tip 💡: For better results, it is recommended to use a replacement image of the same size (width and height dimensions).
Finally, you need to click on the ‘Replace Source File’ button to save your changes.
The plugin will now replace the old image with your new image. You can now visit your website to ensure that the new image is being displayed.
Tip 💡: If you are still seeing the old image, try clearing the WordPress cache.
Method 2: Using Better Search Replace Plugin
For this method, we will be using the Better Search Replace plugin. It is a free plugin with slightly different options than Search & Replace Everything.
The first step is to install and activate the Better Search Replace plugin. For details, see our tutorial on installing a WordPress plugin.
Once you have activated the plugin, go to the Tools » Better Search Replace page to use the plugin.
Simply add the text string you want to search for and then add the text you want to replace it with.
After that, you need to select the tables you want to search in. For example, if you want to search and replace some text in your posts, then you may want to select the posts
table. You can also select multiple tables if you wish.
By default, all searches are case-sensitive. This means that if you search for “Wordpress,” it will not match “WordPress,” “WordPress,” or “WORDPRESS.”
If you want your search to match all those strings as well, then you can make your search case-insensitive.
Optionally, check the ‘Run as dry run’ option.
This will allow the plugin to run a search and show you how many tables and cells will be affected.
Click on the ‘Run Search/Replace’ button to continue.
If you chose the ‘Run as dry run’ option, then the plugin will show you details of affected database tables and cells.
You will then have to run the search again. This time, you will need to uncheck the ‘Run as dry run’ option so that your changes are written in the database.
If you didn’t choose the dry run option, then the plugin will just go ahead and make those changes.
Troubleshooting
You may see the white screen or run into timeouts while performing a search and replace.
If this happens, then you need to click on the ‘Settings’ tab on the plugin page.
You will notice the ‘Max Page Size’ option. Now, try decreasing the page size to avoid timeouts and a white screen.
That’s all. We hope this article helped you learn how to easily perform search and replace tasks in WordPress for bulk changes. You may also want to see our tutorial on how to clean up your WordPress database for improved performance or how to bulk delete WordPress posts.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Dayo Olobayo
Upgrading to the premium version of this plugin was worth every penny. The advanced features like case-sensitivity and selective table targeting saved me so much time. Definitely a must-have tool in my WordPress toolkit.
Daniel
Does the plugin work for bbpress topics and replies too?
WPBeginner Support
The plugin does have the ability to search what was added through other plugins, you would mainly want to make ensure you search the correct tables.
Admin
Paul G
Thanks, this mostly worked for me but didn’t quite change all of the image links.
The rest I could easily change myself by editing the custom modules.
WPBeginner Support
Glad our guide was helpful
Admin
Karol
Changed a website from http to https via cpanel; green lock did not appear and “connection is not secure” warning was present. This plugin worked great for me. The only difference I did was that I left the checkmark off “Case Insensitive?”.
Every site can be different with it’s own hurdles to jump through but the dry run seemed to look okay without any errors so I ran with it. Green lock appeared right away for the site. Plugin worked for me. I hope it continues to work with other sites.
My only question now is … Do I leave the Better Search Replace plugin installed and activated or do I uninstall it now that I’m done?
WPBeginner Support
That would be a personal preference question but you should be able to remove the plugin without worry
Admin
Mandy
Hello,
My site is having issues showing images lately, and my host said that it’s because the paths are wrong. They recommended this plug in, but my problem is that I am not sure what I am searching and replacing. Here’s why:
When I insert an image in “visual” mode within a post, it shows up. They all do.
Then when I preview or publish, some images don’t show up. What I am noticing lately is that instead of the code showing them as “image.jpg”, they now have the image size you choose in the path – “image-300×188.jpg” (this happens to be the medium size for this particular image). Why is it putting the pixel dimensions? If none of the images worked, I could say yes, the paths are incorrect, but some images DO work! I am officially bamboozled. It seems so random.
Best,
Mandy
WPBeginner Support
Hi Mandy,
Please take a look at our guide on how to fix common image issues in WordPress.
Admin
Ashraf Ali
I am switching from http to https now the common problem faced is broken css, I am wondering if could use this plugin to replace https:// to just //
So that all contents are delivered over https
Cheers
Drew
I had a program enter structured data that is all different. I want to remove everything between and including this : ———————-
How would I do that?
WPBeginner Support
Hi Drew,
We are not sure we completely understand your issue. However, we are guessing that you had a plugin to add structured data and now you want to remove the structured data from your WordPress posts and pages? If this is the case, then you can simply uninstall the plugin.
Admin
Sueli
Great plugin!
I have a question.
Can I use a wildcard?
I am trying to remove numbers added after an image file. They are different (both the numbers and their length). The stop point would be the (“).
Some examples of what I want to replace with (jpg”)
(jpg?11906004322295206140″)
(jpg?15231215847335105667″)
(jpg?82668654789154738″)
Is it possible with this plugin?
Thanks
David
I download “Better Search & Replace. Once it found entries, it doesn’t show me unless I buy premium addon.
So instead I ditched that and downloaded “Search & Replace”. It took me only two minutes to replace 100 entries.
Ralpheal
Wow thanks so much, this is truly a luxury. Going to save me a lot of time, as I was considering changing a phone number on 1oo’s of blog posts.
Thanks so much,
Ralpheal
Mike
This plugin did not work for me. I backed up the database, then unchecked “Dry Run”. It messed up things all over the site and there was no way to undo the changes.
I even tried to restore the database backup I created with it before making changes and that didn’t work. Don’t use this unless you’re prepared to do an entire site restoration.
WPBeginner Support
You should have tested with dry run first to see how many rows are affected by the plugin. Glad that you followed the instructions and made a backup first.
Admin
vikas kumar
sir
help me out from pagination error i did which you show in video but i didn’t get result
i am using macbook air in this your given shortcode not work properly
Marko Tiosavljevic
yes, but this plugin is practically useless when it comes to migrations.
When you migrate website from domain . com to another . com you need to change
you need to connect to database for changing url or you need to insert it in wp_config as url
i am working on external app wp safe mode that is solving this problems in best way.
WPBeginner Support
It is highly useful in performing search and replace after you have connected to the WordPress database.
Admin
Nico
Hi, it seems that this plugin is no longer available in Wordpress Plugin Directory. Which alternative plugin do you recommend?
With kind regars,
Nico.
Syed Umair Umar
Better Search and Replace is an alternate for me. The editorial staff of WP Beginner seems too lazy and replies to comments very few times.
WPBeginner Support
Thanks for helping out.
Admin
Brian
Does this take into account serialize data or will it break plugins that use serialized metadata? I know of a few plugins that do this for migration purposes. If it doesn’t it could cause more problems than it solves.