Enter your search term

Search by title or post keyword

How to Perform Search and Replace in WordPress

Level up your digital marketing skills with our free courses, expert insights, forums, and social groups!

Check it Out

Whether you are a new or experienced WordPress user, a time will come when you have to either update or replace several outdated data on your WordPress website database.

That’s where WordPress search and replace comes to play.

Attempting to search and replace all occurrences of certain links, keywords, and phrases on WordPress manually is not ideal for two reasons;

  1. You can make mistakes that could break your website.
  2. It’s also a tedious, repetitive task that takes time.

In this tutorial, you’ll learn fast and error-free methods to perform bulk search and replace in WordPress.

Frequently Asked Questions

Does WordPress Have a Native Search Function?

Yes, WordPress has a default search function called the search widget.

But there’s no native search and replace function on WordPress.

We’ll show you how to do that in this guide.

To add the former to your site, go to Appearance>Widgets> Search widget and click the Add widget button.

What is the Quickest Way to Search and Replace in WordPress?

The quickest way to search and replace in WordPress is by using plugins, especially with recently-migrated sites.

When you use plugins to search and replace in WordPress, you won’t have to tamper with your database directly and will not be dealing with any code whatsoever.

Why Perform WordPress Search and Replace?

When using WordPress, several scenarios could necessitate a WordPress search and replace activity; Changing your website URL from HTTP to HTTPS, correcting certain instances of misspelled words or incorrect phrases, switching to a new domain name or domain extension, changing your brand name and updating keywords for better Search Engine Optimization.

What You’ll Need To Perform Search and Replace in WordPress

To search and replace in WordPress with the methods in this tutorial, below is a list of things to first put in place.

  • WordPress Admin Access: WordPress has 6 pre-defined roles. Each with specific capabilities. You can’t perform search and replace in WordPress except with an admin or super admin role.
  • A Search and Replace Plugin: You’ll need a WordPress plugin designed for your purpose, search and replace. We use the Better Search Replace plugin in this guide.
  • Hosting Dashboard Access: Your website data is stored in a WordPress hosting server. You need to sign in to this hosting account to edit data on your web server.
  • A stable Internet Connection: Using a fluctuating internet connection to access your website database can get you into trouble. Always use a reliable connection.
  • Chrome Web Browser: For the best experience, you need the best web browser, chrome, to perform this operation.

How to Perform Search and Replace in WordPress: 2 Safest Methods

There are several ways to search and replace data on your WordPress database.

While some are secure and straightforward, others are highly technical and no-go areas if you aren’t a WordPress developer.

Some even leave loopholes for hackers to attack your WordPress website.

For clarity and safety, this tutorial focuses on two easy methods that pose no threat to your WordPress security.

  1. Method 1: Using Plugins to Perform Search and Replace on WordPress Database
  2. Method 2: Running MySQL Query to Perform Search and Replace on WordPress Database

Method 1: Using Plugins to Perform Search and Replace on WordPress Database

The simplest and the most popular way of performing search and replace in WordPress is via plugins.

The Better Search Replace Plugin is a free plugin you can use.

Better Search Replace Plugin:

Without leaving your WordPress admin dashboard, this plugin allows to search and replace any data (texts, phrases, and links) in your website database.

Better Search Replace is the favorite of many users because of its dry-run functionality which can’t be found in other search and replace plugins.

This feature allows you to see the outcome of your actions before they are executed.

So you can decide to proceed or hold on with the changes.

Step by Step: Using Better Search Replace Plugin to Perform Search and Replace on WordPress database

Let’s say you’ve just migrated from HTTP to HTTPS, as in http://www.mysite.com to https://www.mysite.com.

To swap this URL across your website, you need to install the WordPress plugin.

After activating the plugin, use these steps:

Open your WordPress Admin dashboard.

On the side panel, hover over Tools and select Better Search Replace from the menu.

1 12

Input the old URL in the Search for field. Add the new URL to the Replace with field.

2 10

Under Select tables, choose where the data you want to replace is stored on the database.

In this case, since you want to replace all instances of the URL, use CTRL+A to select all.

Scroll down to ADDITIONAL SETTINGS and check the box next to Run as dry run.

3 5

Now click the Run Search/Replace button.

Wait for the dry run to complete.

Once you verify everything is as you want, go back to uncheck the Run as dry run box and click the Run Search/Replace button again.

Using Better Search Replace Plugin for texts, keywords, or phrases

You can use the same steps above to replace a wrong phrase or word in your posts, just that you have to select only the post table under Select tables.

Say you’ve been writing bloggingtips instead of BloggingTips for a long time in your posts.

Now you want to make changes. Follow these steps:

Input the wrong word in the Search for box and the correct word in the Replace with box.

4 5

In this case, the table to choose under Select tables is the wp_posts table only.

You can use the dry run to confirm changes before completing the process.

Other Search and Replace Plugins

Search and replace plugins only have different interfaces.

They have similar features and operate almost the same way.

Below are 3 other search and replace plugins to try out:

  1. CM Search and Replace Plugin
  2. Search & Replace Plugin by Inpsyde
  3. Search Regex plugin

Method 2: Running MySQL Query to Perform Search and Replace on WordPress Database

If you dislike the option of another WordPress plugin on your website and would love to get witty about search and replace, using this method will have your hand full.

You don’t need to be a tech guru to write a MySQL query. You only need to be good at following instructions. Let’s go.

Before running the MySQL query on your WordPress database, you must identify the database you are trying to edit.

This step is crucial if you have more than one database on your account. Here’s how;

Log in to your web hosting account, go to Files, then File manager to open your website file.

1 13

Open the public_html folder, locate the wp-config.php file from the list. Double-click to open it.

2 7

Check for the line that reads “define(‘DB_NAME’, ‘Database Name ‘);.”

1 10

That’s your WordPress database name. Take note, as that is the database you’ll be working on next.

Step-by-Step: Writing MySQL Query to Perform Search and Replace on WordPress Database

On your hosting account dashboard, Click on Database.

4 3

Select your WordPress database from the list, then click on the Enter phpMyAdmin button.

5 1

On the top of your phpMyAdmin page, switch to the SQL tab and enter this code snippet into the textbox:

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'Text to search, 'Text to replace it with');


7 2

Note: You must replace all the placeholder text in the code snippet with the appropriate text.

Let’s use the bloggingtips and BloggingTips example above to illustrate what each placeholder text stands for.

TABLE_NAME: The name of the table you want to edit. (wp_posts)

FIELD_NAME: Where the data you want to change is located in the table. (post_content)

Text to search: The word or phrase to change. (bloggingtips)

Text to replace it with: The new word or phrase (BloggingTips)

Now, our code snippet looks like this;

update wp_posts set post_content = replace(post_content, 'bloggingtips, 'BloggingTips');
12 1

Once you are done writing the query, click on the Go button at the bottom right corner of the page to execute it.

22 1

More Helpful WordPress Tutorials

  • How to Clear WordPress Cache: If your WordPress website is loading slowly, clearing your WordPress website cache can help. Check this guide.
  • How to Update WordPress: An out-of-date version of WordPress can lead to plugin and theme compatibility issues on your website. Learn how to update WordPress.
  • How to Redirect a WordPress Page: Do you want to migrate your WordPress website, you first need to know how to redirect a WordPress page.

Wrapping up

While there are other methods to perform search and replace on WordPress database, we only encourage website owners to use these two.

Besides being the more straightforward options available, using them poses no security threat to your website. Other methods do.

Whether you want to update SEO keywords and URLs or correct grammatical errors, this WordPress search and replace guide will always come in handy.

Which method would you prefer? Let us know in the comment section down below.

Leave a Comment