There are cases where you may need to replace all occurrences of specific strings in your WordPress site with another.
For example, when you have just uploaded a picture and want your WordPress site to use a specific name instead of the current one or when you simply want to change the name of the picture.
You can do this easily with WordPress plugins such as Better Search and Replace.
Step 1. Install and activate the Better Search Replace plugin.
To install the plugin, you can search for it straight in your WordPress Dashboard (you can log in to your backend area by adding /wp-admin at the end of your website’s URL, eg. https://mywebsite.com/wp-admin).
Click on Add New (1) in your Plugins menu, then type Better Search Replace (2) into the search bar. Press Install Now (3) next to the plugin, and then activate.
Once it’s activated, you can find the plugin’s settings in the Tools area of your WordPress dashboard:
Step 2. Backup your Database.
Step 3. Choose the old URL and the New URL.
For example, let’s say you have a broken picture in your media that you need to update to fix it. To fix the image, you need to replace the old name with the correct one. In our example, we will be changing “NEW-WPX-LOGO-new” to “NEW-WPX-LOGO”.
In that case, you need to go to the Better Search Replace from the Tools options and change it.
Step 4. Dry run search and replace.
Go to Tools in your WordPress dashboard and then select Better Search Replace.
In the first section (1), you need to add the Old URL, that you will be changing and next to it you need to add the New URL. In our example, we want to change “NEW-WPX-LOGO-new” to “NEW-WPX-LOGO”.
Then select the option Run as dry run (2) which allows checking the results beforehand without making any changes in the database. Then you need to select the table/s (3) that you want to search and replace with Ctrl-Click for Windows or Cmd-Click for Mac (you can select all of them) and hit the Run Search/Replace -> button (4):
After the dry run is completed you will see how many rows need to be updated:
Step 5. Search and replace string,
If you want to proceed with those changes, you need to uncheck the dry run option (1) and hit the Run Search/Replace again (2):
Now you will see that the changes were already made in the database which means that we already changed the string from NEW-WPX-LOGO-new to NEW-WPX-LOGO:
Then we can just check again the Media and see that the picture is already visible and the name is changed, which means that our job is perfectly done:
If you get stuck with anything discussed on this page, please get in touch with WPX Support Team via live chat (use the bottom right-hand widget) and they will respond and help within 30 seconds or less.