Last week I wrote up a post to review the Real-Time Find and Replace Plugin and the comments on that story about other methods to make site wide changes permanent sent me in search of another way to search and replace information in my SQL database.
Now I consider myself pretty decent at geeky things but directly editing and messing with my site’s SQL database does not top my list of things to do. Neither does manually going through nearly 1,000 postings to make changes.
What I found was a terrific plug-in that lets me perform a few different functions to make corrections or change info throughout my site.
Caveat: Before I get started – this plugin does make changes to your database. Play it safe and back up your info to protect your original data.
With that said let me now introduce you to the Search Regex Plugin written by John Godley.
The author provides the following description in the WordPress.org Plugin Directory:
Search Regex adds a powerful set of search and replace functions to WordPress. These go beyond the standard searching capabilities, and allow you to search and replace almost any data stored on your site. In addition to simple searches you have the full power of PHP’s regular expressions at your disposal.
The plugin is currently at version 1.4.9 and is dated from July 2009 however it is fully compatible with WordPress Version 2.9.1.
So once you have downloaded and installed the plugin head to the Tools menu in the Admin interface:
Click on Search Regex to get to the main admin page:
From this spot you can either Search; Replace or Replace and Save. Only the last one makes permanent changes to your database when you push the button.
Lets review the options you can set for each one:
Source Dropdown Menu lets you pick the areas in the database that will be searched.
Limit to Dropdown Menu restricts the number of entries that will be searched. This can be handy on a large site.
Order By lets you choose to display the results of a search in either Ascending or Descending order.
Once you make those choices you are ready to search. Type the phrase you want to find in the Search pattern box. I found that multi-line searches do not work so well with this plugin so I recommend you keep it short and exact.
If all you want to do is find a handful or articles that have a certain phrase or word in them then click the Search button and you will see the following type of results:
Each entry is on an alternating color line and if you look all the way over to the right on each line there is a link to either View the post as it appears on your site or Edit the post using the normal WordPress Edit screen. No changes are made to your database by using the Search button.
The next button you can use is the Replace button and this one lets you preview the changes that would be made for each entry that matches your search and replace criteria. Those results show up like this:
Just like with the Search button results, if you look over on the right hand side you will see links to either View the post, perform the Replace function for that entry only or open the post up using the standard WordPress admin edit screen. If your only making a few changes this is very handy to do them one at a time to make sure your changing the info you want to change.
The last option you can use is one of the most powerful because it makes the change after you press the Replace and Save button. With this one you want to make sure the edit is exactly what you want to do. I recommend using the Replace button first to preview the matches it finds before executing the Replace and Save.
I do not have a screen shot to show you that function because honestly I do not have a change to be made right now. However, the results page looks a lot like the Replace results except they have been made instead of just displayed for review.
So there ya go – a very powerful tool in a small package. Let me close by repeating an earlier reminder – back up your database before executing any major changes using this plugin. You will be thankful that you did if you hit the wrong button
So which do you prefer – this permanent change or the on the fly changes that are made by the Real-Time Find and Replace Plugin?