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

David Hayes

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)!

Most Searched Articles

Best JavaScript Libraries and Frameworks: Try These 14 in 2024

In this post, we look at the best JavaScript libraries and frameworks to try out this year. Why? Well, with JavaScript being available in every web browser, this makes it the most accessible programming language of ...

25 Best Free WordPress Themes (Responsive, Mobile-Ready, Beautiful)

If you're looking for only the best free WordPress themes in the market for this year, then you're in the right place. We have more than enough such themes for you right ...

12 Best WordPress Hosting Providers of 2024 Compared and Tested

Looking for the best WordPress hosting that you can actually afford? We did the testing for you. Here are 10+ best hosts on the market ...

Handpicked Articles

How to Make a WordPress Website: Ultimate Guide for All Users – Beginners, Intermediate, Advanced

Many people wonder how to make a WordPress website. They’ve heard about WordPress, its incredible popularity, excellent features and designs, and now they want to join the pack and build a WordPress website of their own. So, where does one get ...

How to Start an Ecommerce Business: Ultimate Guide for 2024

Is this going to be the year you learn how to start an eCommerce business from scratch? You’re certainly in the right place! This guide will give you a roadmap to getting from 0 to a fully functional eCommerce business. ...