Looking to find out the best way(s) to perform WordPress Search and Replace Easily? Then this article is exactly what you need to read.
When it comes to managing your WordPress website, making certain minor changes is not usually a big deal. However, at times you may need to change many elements on your site at once. This is where the “WordPress search and replace” comes into play.
For example, perhaps you just migrated from HTTP to HTTPS and you will need to update all of your hard-coded HTTP URLs in the WordPress database. Alternatively, you are changing domains and need to update all your database references.
There are many other scenarios in which knowing how to perform a bulk WordPress search and replace can save you a lot of time.
This article is aimed at highlighting what the concept of WordPress Search and Replace means when to do so and ways to perform this action.
An Overview of WordPress Search and Replace
There are certain situations in which a user may need to perform the WordPress search and replace on his or her WordPress site.
One of the common scenarios is when you want to replace a text such as a disclaimer or a bio that you added to multiple pages or posts but you do not know every place it is currently located.
Being able to conduct a mass search and replace saves a lot of time in contrast to searching every single post and page for the text you want to switch out.
Performing the WordPress search and replace is not restricted to texts only. You can also perform it for URLs and images. In a nutshell, this functionality comes in handy if you want to
- Update SEO keywords
- Correct a grammatical or spelling issue
- Remove certain words or special character
- Update your HTTP URLs to HTTPS after a migration.
- Move your site from www to non-www URLs and vice versa
- Update shortcodes, contents, or strings of texts.
However, it is important to know that in performing this action there is no undo option. That is to say, you cannot get back to the older version. This means to get back to the older version you will have to perform another mass WordPress search and replace.
To be on the safe side, you must perform a backup before any WordPress search and replace routine.
Here are the best Backup Plugins for your WordPress Site in 2023. All Plugins have been reviewed expertly by your’s truly.
How to Perform WordPress Search and Replace
There are a lot of ways to perform the WordPress search and replace. The recommended methods include.
- Installing a WordPress Search and replace plugin.
- Using the interconnect / it Search and Replace DB PHP script.
- Using the WP- CLI.
- Using PHPMyAdmin from your Hosting Dashboard.
Installing WordPress Search and Replace plugin
One of the best plugins one can use for this process is the “Better Search Replace” plugin. This plugin is developed by the WordPress team over at Delicious Brains and it is inspired by the interconnect / it PHP script.
The plugin comes with many interesting features such as
- Sterilization support for all tables
- Ability to select specific tables
- Option to conduct a dry run to see how many fields will be updated.
- No server requirements aside from a running installation of WordPress and WordPress multisite support.
This tool can be used to solve hundreds of different cases. In the Better Search Replace options, you can easily search for any hard-coded HTTP references and update with HTTPS versions. The plugin also has a pro version which gives you access to more interesting features.
Another plugin that can be able to carry out this process is the “Search Regex” though it is not as sufficient or widely popular as the WordPress search and replace plugin.
You can download either plugin via the WordPress Repository. Alternatively, you can search for them within your WordPress dashboard under plugins and then “add new”.
Using the interconnect / it Search and Replace DB PHP script
This is another method of performing the WordPress search and replace action. It involves using a free PHP script from interconnect /it called “Search Replace DB”.
It is important to note that using this script may break your website if you are conversant with how to use it. It is therefore advisable you contact your web host or a developer first before initiating the process.
This script has been in existence since 2011 and web developers constantly update it. To use a script, simply download the zip file and extract the folder called Search Replace DB Master and rename it to something of your choice. Let’s say I want to rename mine with the name ” update -DB-1551.
Next, upload the file via FTP or SFTP to your web server’s public directory. This is the same directory that contains your WP content folder. Then navigate to your secret folder in your browser such as “https:// domain.com/update- db-1551”.Then the script will automatically try to find and populate the database field.
However, you must check to ensure that the details are correct and are the right ones for a database you wish to carry out the search and replace operation on. You can click on “dry run” first to see a preview of what the script will be updating and replacing.
When you are ready, select a “live run” which will perform the database updates in the WordPress search and replace. For security reasons you should delete the script after you are done. To do this simply select the “delete me button” because if not done it leaves your website susceptible to attacks.
Using WP -CLI
This option is mostly used by WordPress developers. Specifically for kinsta customers, they are provided with access to SSH so that their customers can use the WP -CLI.
An example of such commands includes
” wp search-replace ‘http://example. “
Run a Find and Replace MySQL Query With PhpMyAdmin
This method can be used if you are comfortable working with codes and do not want to make use of plugins to perform a WordPress search and replace. However, this process should be carried out by a WordPress developer.
If your hosting provider makes use of cPanel and browse to and select phpMyAdmin under databases. For kinsta customers, phpMyAdmin is accessible via the myKinsta dashboard.
To do this click on your site and the database access section, click on open phpMyAdmin and a new tab opens where you will now input your database name and password.
Once you are done putting down the correct details select “go”. Once you have access to phpMyAdmin, locate your database name. Then select the SQL tab and add the following code;
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'Text to search, 'Text to replace it with');
Then click on the Go button to run your SQL query. When the process is done, it will display a success message indicating the number of changed instances. You can also visit your site to confirm if the search and replacement were successful.
Learning how to perform WordPress search and replace is beneficial and time-saving.
Fortunately, there are many methods by which this process can be achieved. Hopefully, this article has gone a long way in enlightening users on how to carry out WordPress searches and replace them.
If you want to learn more about WordPress and how to fix a couple of WP issues you can checkout my category and also the related posts section below.