With WordPress, all of your content is stored in a database (called a MySQL database or SQL file) on your server, not page files. This means that if you need to make global changes to your content like replacing text or URLs throughout your site, these changes have to be made inside your WordPress database tables.
Editing database tables, however, requires having knowledge of MySQL. If you are a non-coder and need to make global changes to content on your website, the best way to do this is to use a WordPress plugin.
In this tutorial, you will learn how to use plugins to easily perform a global search and replace in WordPress without touching code or editing your WordPress database tables.
How To Do A Global Search And Replace In WordPress
Being able to change content throughout your site quickly is important if you have many instances of text or links that need replacing, for example:
- Changing a product/brand name or multiple product descriptions,
- Replacing staff member names, telephone numbers, physical addresses, email addresses, etc.
- Replacing misspelled words
- Translating words
- Changing internal/external website URLs
- etc.
Imagine the following scenarios:
Also, let’s say that your WordPress site includes many published posts and pages containing images stored inside your WordPress media folder.
As your site grows and new posts and pages get added, you then decide to move all of your images and media to an external storage location (e.g. Amazon S3) to help improve your site’s efficiency and make your pages load faster to visitors …
(Transferring images to different storage locations require replace image URLs on existing content)
This transfer changes the path (i.e. the destination URL) of your images, which requires changing the URLs of all the images that you have added to your posts and pages.
In most situations, it would be quite impractical to go through every post and page on your site and do a manual search and replace of all image links. Fortunately, if you are a non-tech-savvy WordPress user, plugins provide a simple solution you can use to search and replace content throughout your site without having to access your WordPress database.
If you transfer images to a different image storage location without changing the URL of the images in your content, your posts and pages will continue displaying images stored in the old location (e.g. your WordPress images folder).
If you delete your images from the WordPress images folder or change image URLs before transferring images to the new location, your posts and pages will display “missing image” errors …
(Incorrect image links lead to missing image errors)
When transferring images published on existing content to a different storage location, follow the steps shown in the order below to avoid errors:
- Add images to the new location
- Write down the destination path to the new images folder
- Perform a global search and replace to change the old path URL to the new destination using a search and replace plugin
- Delete images from the old folder or just ignore these.
- All of your image links will now point to the new storage location.
Search And Replace
(Search & Replace – WordPress global search and replace plugin)
Search & Replace is a free plugin that allows you to perform a simple search to find strings in your WordPress database and then replace that string.
You can search for content strings in areas of your database such as ID, post-content, GUID (Globally Unique Identifier), title, excerpt, meta-data, comments, comment-author, comment-e-mail, comment-url, tags/categories, categories-description, and many others. You can also use this plugin to replace the user-ID in all tables and the user-login for site security purposes.
Plugin Download
You can download the Search And Replace WordPress plugin here:
https://wordpress.org/plugins/search-and-replace/
Plugin Installation
To install Search And Replace, log into your WordPress dashboard, go to Plugins > Add New …
(Plugins Menu – Add New)
Type in “search-and-replace” in the Search field and click on Search Plugins …
(Add Plugins Menu > Search And Replace)
Locate the ‘Search & Replace’ plugin and click Install Now to install the plugin …
(Install Search & Replace)
Activate the plugin after installation …
(Activate the plugin)
You can also activate your plugin by going to Plugins > Installed Plugins …
(Plugins Menu – Installed Plugins)
This brings you to the ‘Plugins’ screen …
(Plugins screen)
Locate the ‘Search & Replace’ plugin in the ‘Plugins’ screen and click Activate …
(Activate the plugin)
The plugin will be activated and ready to use …
(Search & Replace plugin is now active)
Plugin Usage
To access the plugin’s search and replace features, go to Tools > Search & Replace …
(Tools > Search & Replace)
This brings you to the ‘Search & Replace’ page …
(Search & Replace screen)
Using The Search & Replace Plugin
The Search & Replace plugin allows you to perform a number of useful functions, including:
- Backing up your database
- Replacing domain URLs
- Importing MySQL database data
For the purposes of this tutorial, let’s focus on searching and replacing text strings.
Click on the ‘Search & Replace’ tab …
(Search & Replace tab)
Here you can search for text or strings in all database tables, or just in specific tables, and perform global or specific search and replace operations …
(Search & Replace fields)
Backup your WordPress site before using this plugin! You cannot undo the changes made to your database by the plugin.
Using our previous example, let’s say that you want to replace all instances of the old link structure where images were being stored with links pointing to your new image folder location …
(Let’s replace all instances of this URL)
First, make a backup of your WordPress database, then go to Tools > Search & Replace and do the following:
- Enter the URL to be replaced in the Search for: field (1)
- Enter the new URL into the Replaced with: field (2)
- Check Select all tables to find and replace strings in all of your database tables or select only the specific database tables to perform the search and replace function by clicking on individual table items (3)
- As a safety precaution, we recommend leaving the Dry Run box ticked. If you uncheck this box, the plugin will begin performing a search and replace as soon as you click the start button.
- Click on ‘Do Search & Replace’ to begin …
(Search & Replace)
The plugin will begin to search and replace the strings in your WordPress database and let you know when the operation has been completed …
(Search and replace results)
When performing a ‘dry run’, no changes will be made in your database. You can view the results by clicking on the ‘View details’ link …
(Search & Replace – View details)
To perform the changes, repeat the process, but change the following settings:
- Make sure ‘Select all tables’ box is ticked
- Deselect ‘Dry Run’ checkbox
- Select the ‘Save changes to Database’ option in the ‘Export SQL file or write changes to DB?’ setting …
(Use these settings to perform the actual search and replace)
The plugin will perform the search and replace operation and save the changes to your database.
(Search and replace operation completed)
If you don’t want to save the changes to your database, you can export an SQL file with the changes instead (useful for developers) …
(Making a search and replace to SQL file instead of your actual database)
Once the operation has been performed, go back to your post or pages and check the results …
(Global search and replace performed!)
The old image links on all of your posts and pages have now been replaced.
For more information about this plugin, visit the plugin site here:
Alternative Search & Replace Plugins
In addition to the Search & Replace plugin described above, there are other search and replace plugins that you can use.
Better Search Replace
(Better Search Replace Plugin)
Better Search Replace consolidates and incorporates the best features from many search and replace plugins, incorporating the following features in one simple plugin, including:
- The ability to select specific tables
- The ability to run a “dry run” to see how many fields will be updated
- No server requirements aside from a running installation of WordPress
- WordPress Multisite support
- A ‘PRO’ version with advanced/additional search and replace features
For more details, go here}:
Real-Time Find And Replace
(Real-Time Find and Replace Plugin)
This plugin allows you to dynamically (i.e. at the time when a page is generated) replace code and text from themes and other plugins with code and text of your choosing before a page is delivered to a user’s browser. Because the find and replace happens in real-time no changes are needed to plugins or themes. A ‘PRO’ version is available with advanced/additional features.
For more details, go here}:
Text Replace
(Text Replace Plugin For WordPress)
This plugin allows you to easily define text or HTML that should be used in your posts in place of words or phrases that are actually present in the posts. This is a handy technique for creating shortcuts or content ‘placeholders’ to common, lengthy, or frequently changing text/HTML, or for smilies.
For more details, go here}:
You can search for more search and replace plugins inside your WordPress dashboard (Plugins > Add New), or the WordPress Plugin Repository …
(WordPress Plugin Search – search and replace)
Search the WordPress Free Plugin Directory for search and replace plugins below:
Congratulations! Now you know how to perform a global search and replace in WordPress without touching code or editing your WordPress database tables.
(Source: Pixabay)
***
"These tutorials have so much information and are easy to understand. If you use WordPress or plan to in the future these will help you with everything you need to know." - Valisa (Mesa, Arizona)
***