WordPress Search and Replace (5 Methods)
Making tiny modifications here and there isn’t normally a big deal when it comes to managing your WordPress website. However, if you need to edit multiple items on your site at the same time, you may need to use WordPress search and replace.
For example, if you recently switched from HTTP to HTTPS, you’ll need to update all of your hard-coded HTTP URLs in the WordPress database. Alternately, you might be switching domains and need to update any database references. Knowing how to execute a mass WordPress search and replace can save you a lot of time in a variety of situations.
We’ll go through what a WordPress search and replace is and when it could be necessary in this piece. Then we’ll show you how to do it in five different ways.
Let’s get this party started!
Contents Table of Contents
An Overview of WordPress Search and Replace
How to Find and Replace Words in WordPress (5 Methods)
Whether you’re switching from HTTP to HTTPS, moving domains, or making a large number of changes to your site, search and replace makes it simple. ✅ To learn more, click here.
TO TWEET, CLICK HERE
Do you like to watch the video?
Search and Replace in WordPress: A Quick Overview
There are a few times when you’ll need to execute a search and replace on your WordPress website. One of the most common circumstances is when you need to replace a piece of content (such as a disclaimer or bio) that you added to many pages or posts but don’t know where it is.
When compared to manually searching every post and page for the text you wish to replace, being able to execute a mass search and replace saves a lot of time. Plus, this method is applicable to more than simply text.
You may do a mass WordPress search and replace for URLs and images in your WordPress database, for example. This feature comes in helpful if you need to:
Keywords for Search Engine Optimization (SEO) should be updated.
Make a grammatical or spelling correction.
Remove any words or special characters you don’t want.
After a migration, change your HTTP URLs to HTTPS.
Change your website’s URLs from www to non-www (or vice versa)
Update any old shortcodes, content, or text strings.
We’d like to point out that there is no ‘undo’ option. You can’t go back to the old version once you’ve replaced the text or other information. To reverse the procedure, you’d have to perform another mass search and replace. That’s why, before beginning any WordPress search and replace procedure, we strongly advise you to make a backup.
How to Perform a WordPress Search and Replace (5 Methods)
A WordPress search and replace can be done in a number of different ways. Let’s take a look at five possibilities that come highly recommended.
1. Use the Search and Replace feature in MyKinsta.
You can use our own search and replace tool if you’re a Kinsta customer. It’s accessible from the MyKinsta dashboard. To find this tool, go to Sites and then to the name of the website you wish to perform the search and replace on:
The dashboard for MyKinsta.
After that, go to Tools and select the Search and Replace option:
replace mykinsta with mykinsta
Kinsta’s Search and Replace feature.
As previously said, this tool can be used for a variety of various procedures. In this example, we’ll change some “http” URLs to “https” URLs.
Enter the value you wish to look for in the database in the search field and click Search. The number of occurrences for the specified string will be displayed by the search and replace tool:
search box on mykinsta
Using the MyKinsta search and replace tool, I conducted a search.
Continue with the process by checking the Replace box. Enter the new text, URL, or other value in the Replace with field:
replace field with mykinsta
In the MyKinsta search and replace tool, the Replace field.
To automatically delete your site’s cache after the search and replace procedure, leave the Clear cache when ready option checked. Visitors will be able to see the most recent version of your website immediately away. Then select Replace from the drop-down menu.
You’ll receive a confirmation popup after the WordPress search and replace is finished, displaying the number of replacements that were executed. To quit the search and replace tool, pick Cancel after you’re finished. That concludes our discussion.
2. Add a WordPress Search and Replace Plugin to your site.
You can also use a plugin if you’re not hosting with Kinsta or if you want another way to execute a WordPress search and replace without manually scanning your database. Better Search Replace: This is a popular solution for this.
better replacement for search
Better Search Replace is a WordPress plugin that allows you to replace your default search engine.
The Delicious Brains WordPress team created the Better Search Replace plugin, which was inspired by the interconnect/it PHP script, which we’ll discuss in the next way.
Better Search Replace hasn’t been updated in several months as of this writing. Although we haven’t had any problems when testing it, we strongly advise making a backup of your site and testing it in a staging environment before deploying it to a live site.
Among the benefits of Better Search Replace are:
All tables have serialization support.
The option to pick and choose which tables to visit.
The ability to perform a “dry run” to determine how many fields will be changed.
Aside from a working WordPress installation, there are no server prerequisites.
Multisite compatibility in WordPress.
This tool can be put to hundreds of various uses. As seen in the example below, you can easily search for any hard-coded HTTP references and replace them with HTTPS versions using the Better Search Replace options:
alternatives to search for and replace
Options for the Better Search Replace plugin.
A pro edition of the plugin is also available, which provides access to even more capabilities. For more information on how to make the most of this plugin, see the official documentation.
Search Regex is another tool you might want to look into:
Do you want to discover how we grew our traffic by over 1000%?
Join the 20,000+ people who receive our weekly email with WordPress insider secrets!
Now is the time to subscribe to the Regex WordPress plugin.
The WordPress plugin Search Regex.
While it’s adequate for basic search and replace jobs, such as altering URLs and content in bulk, this plugin isn’t as well-known or extensively used as Better Search Replace. Nonetheless, it’s a well-maintained and well-rated gadget that gets the job done and is easy to use.
Either option is available for download from the WordPress source. You can also look for them in the Plugins > Add New section of your WordPress dashboard.
3. Replace the DB with the interconnect/it Search Script in PHP
It’s possible that you won’t want to add another plugin to your WordPress site. If that’s the case, you can also utilize a free PHP script from interconnect/it called Search Replace DB: Replace to execute a WordPress search and replace.
webpage that connects it
interconnect/it is a website that connects people.
It’s crucial to remember that if you don’t know what you’re doing, this script could ruin your WordPress website. If you are unsure about using this strategy, consult a developer or your web provider first.
The makers of this script have been constantly updating it since 2011. To use the script, simply download the zip file, extract the “search-replace-db-master” folder, and rename it to whatever you want.
We renamed it “update-db-1551” in our example:
script to connect search and replace
The Interconnect search and replace script is being uploaded.
Then, using FTP or SFTP, upload the file to your web server’s public directory. This is usually the same directory as your /wp-content directory. Then go to “https://domain.com/update-db-1551” in your browser to find your private folder.
The script will try to find and populate the database column on its own. You must, however, double-check that the details are valid and that they are the exact ones for the database on which you want to perform a search and replace operation.
You can start with a dry run to check what the script will update or replace. Select live run when you’re ready, which will do the database updates as well as the WordPress search and replace:
replace interconnect search
Using a WordPress database to perform a search and replace.
It’s also critical that you delete this script once you’re finished for security reasons! You can do this by selecting the erase me button.
Do you require a hosting solution that can provide you a competitive advantage? With remarkable speed, cutting-edge security, and auto-scaling, Kinsta has you covered. Take a look at our plans.
If you don’t, your website may be vulnerable to cyber-attacks. It’s also a good idea to double-check your web server to make sure the folder and script are gone.
4. Run a search and replace WP-CLI with the results.
Another option for performing a WordPress search and replace is to utilize WP-CLI directly. For the WordPress devs out there, there is an option.
We provide SSH access to Kinsta customers so they may use WP-CLI. If you’re new to WP-CLI, we have an in-depth guide to administering WordPress from the terminal as well as a curated list of essential SSH commands.
Here’s an example of how to use the command:
wp search-replace ‘http://example.dev’ ‘http://example.com’ ‘http://example.dev’ ‘http://example.com’ ‘http://example.com’ ‘http:// —recurse-objects —all-tables —precise
The official WP-CLI documentation has more information on the arguments available for the wp search-replace command. You might also want to take a look at this WP-CLI guide for sophisticated search and replacement.
5. Use phpMyAdmin to find and replace MySQL queries.
You can also use MySQL query in phpMyAdmin if you’re experienced dealing with code and don’t want to need a plugin to execute a search and replace in your WordPress database. However, only expert WordPress developers should do so.
If your hosting provider utilizes cPanel, go to Databases:phpMyAdmin and pick phpMyAdmin.
PhpMyAdmin may be found under the ‘databases’ section of cPanel.
Customers of Kinsta get direct access to phpMyAdmin via the MyKinsta dashboard. To begin, go to your website and click on it. Scroll down to the Database access area of the Info page and click Open phpMyAdmin:
In the MyKinsta dashboard, click the phpMyAdmin link.
The phpMyAdmin login page will appear in a new tab. Select Go: after entering your database username and password.
phpMyAdmin login kinsta
The phpMyAdmin login page for Kinsta.
Locate the name of your database in phpMyAdmin once you’ve logged in. Navigate to your File Manager if you need assistance. Open your wp-config.php file in the public html folder and look for the line “define(‘DB NAME’, ‘Database Name’);”.
Next, go to the SQL tab in phpMyAdmin:
In phpMyAdmin, go to the ‘SQL’ tab.
Add the following code to your page:
set FIELD NAME = replace(FIELD NAME, ‘Text to search,’Text to replace it with’); update TABLE NAME set FIELD NAME = replace(FIELD NAME, ‘Text to replace it with’);
Then, to run your SQL query, click the Go button. When the procedure is complete, a success message will appear, displaying the number of altered instances. You may verify that the search and replace worked by going to your WordPress site.
Don’t waste your time making tiny changes to your #WordPress site. To quickly and easily deploy changes and get started with your new and better site, use search and replace.
TO TWEET, CLICK HERE
Learning how to execute a mass search and replace is really useful, whether you’re wanting to update your keywords or replace a single piece of text across all of your posts. Fortunately, there are a variety of approaches you can take.
For a WordPress search and replace, we propose using the following five techniques:
In your MyKinsta dashboard, use our own search and replace tool.
Install Better Search Replace or Search & Replace, a WordPress search and replace plugin.
Use the PHP script interconnect/it Search Replace DB.
Using WP-CLI, perform a direct search and replace.
Using phpMyAdmin, run a MySQL query.
Save time, money, and improve site performance by using:
Expert WordPress hosting assistance is available 24 hours a day, 7 days a week.
Integration with Cloudflare Enterprise.
With 29 data centers across the world, we can reach a global audience.
With our built-in Application Performance Monitoring, you can improve your performance.
All of this and more is included in a single plan that includes no long-term obligations, aided migrations, and a 30-day money-back guarantee. Check out our plans or speak with a sales representative to find the ideal plan for you.