Skip to content

Change Database Values with Better Search Replace in the WordPress DB

Most people in WordPress know that there exists a “database” somewhere in the whole system. And they might also know that there are times you’ll need to do a little “search and replace” within that database. This is useful if you’re looking to change a string you’ve used across a whole array of posts, of if you’ve just moved your site to a new URL. While the full details of the second case—migrating a WordPress site to a new URL—are well beyond the scope of this Quick Guide, we’ll cover a plugin that can be really useful if you’re doing that too: Better Search Replace.

Quick Video Tour of Search-and-Replace in the WordPress Database

How the Change Strings in Your WordPress Database with Better Search Replace

  1. As you might guess, you’ll install the “Better Search Replace” plugin by going to “Plugins > Add New” in your left-side WordPress administration menu.
  2. On “Add plugins” screen, you’ll run a search for “Better Search Replace,” the name of the plugin maintained by the folks at Delicious Brains. “Install” and then “Activate” the plugin.
  3. You’ll then use the plugin by going to the “Tools > Better Search Replace” (if you don’t see it, you’ve not installed and activated the plugin successfully 🤓)
  4. The plugin’s interface is pretty clear, you’ll specify the thing you want to “Search for” followed by what you’ll like to “Replace with“. To be even more clear, you’ll put “MY OLD STRING” in the “Search for” field, and “My Cooler New Text String” in the “Replace with” field.
  5. Then you’ll select the tables you want to run this replacement on. For the example of “I have an old company name” or “I used to like to URL1 and I now want those posts/pages to link to URL2” you’ll probably just need to select the wp_posts table (prefixes differ, but XXXXX_posts will be the consistent pattern).
  6. Then click “Run Search/Replace” and your text will be changed. It’s really that simple. (I do like using the “Run as dry run?” option, so that I can see how much of a change I’ll make before that change gets completed in the database. But that’s not really necessary.)

Best wishes, and be careful in your database :p

Yay! 🎉 You made it to the end of the article!
David Hayes
Share:

0 Comments
Inline Feedbacks
View all comments

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!