Introduction

On a website, there is a lot of content presented. It can be a text, image, or URL. However, when there are too many posts containing a lot of content, you will find it difficult to search any content that already exists on your website. If you are looking for a way to quickly find and replace text in your WordPress database, let’s check out today’s blog!

To make it easier for you to visualize, let’s see the following example. In the past, during content creation and development, you added a specific URL to some posts. However, that URL is no longer needed, so you want to find the posts containing this URL to remove and replace it with something else. Thus the question is, how do you find all these posts? If you just do a normal manual search, you will most likely miss some posts and spend a lot of time searching. Because of this reason, in today’s article, we will guide you to do this by using a plugin or phpMyAdmin. As a result, you can save time but still easily find and replace content in posts. Let’s go now!

The ways to find and replace text in WordPress database

Although using a plugin or phpMyAdmin can save time and effort, there is a downside to these methods. That is, once you have made changes to the database, you will not be able to undo the changes so that the content is back to the way it was. Therefore, you need to create a database backup through the WordPress Backup Plugins. In addition, you can also store the database by creating backups with phpMyAdmin.

After storing all WordPress databases, let’s start to find and replace text now!

Using a plugin

First of all, let’s go to Plugins -> Add New, then find Better Search Replace plugin on the search bar. After that, you simply need to click on Install Now -> Activate button.

Find And Replace Text 1

After installing and activating the plugin, on the admin dashboard, let’s access Tools -> Better Search Replace.

Now, the Search/Replace section appears to allow you to add the text string you need to find and replace.

Let’s see our instance. We want to search for the word ‘abc’ in all posts and change it into ‘goodbye’. So, we will enter the word ‘abc’ in the Search for box and fill out ‘goodbye’ in the Replace with box. Then, we will choose wp_posts at the Select tables because we wish to find and replace the text in all posts.

Finally, don’t forget to click on Run Search/Replace to start the progress now.

Find And Replace Text 2

Sometimes, when you run the search and replace progress, you may see the run into timeouts or a white screen. Don’t worry about that. All you need to do is open the Settings section, then try to decrease the page size. Everything is done.

Find And Replace Text 3

Utilizing phpMyAdmin

If you don’t like to use a plugin to find and replace text in the WordPress database, you can also utilize phpMyAdmin to do that.

Firstly, let’s log in cPanel dashboard of the WordPress hosting, then find the database section and select the phpMyAdmin icon.

Now, you need to click on the SQL part and paste the following code:

update TABLE_NAME set FIELD_NAME =
replace(FIELD_NAME, 'Text to find', 'text to replace with');

For instance, you desire to find the text in the post’s content, you just need to change FIELD_NAME to post_content, like this:

update wp_posts set post_content =
replace(post_content,'Text to find','text to replace with');

Finally, simply press the Go button so that phpMyAdmin can run the SQL query. When this progress success, there will be the number of rows that are affected by the SQL query.

Understanding the database tables in WordPress

wp_commentmeta: This table will provide you with meta-information about comments on your site. It has 4 fields, including meta_id, comment_id, meta_key, and meta_value.

wp_comments: This table contains comment author names, emails, comments, URLs, and more.

wp_links: It will control blogrolls.

wp_options: It contains the WordPress site-wide settings. Besides, it is also used in order to store plugin settings.

wp_postmeta: It contains meta-information about posts, pages as well as custom post types.

wp_posts: This table has all the posts, revisions, custom post types, and pages.

wp_termmeta: It lets the developers save custom metadata for terms.

wp_terms: It a taxonomy system that lets you organize the content.

wp_term_relationships: This table will help you manage the relationship between post types and terms in wp_terms.

wp_term_taxonomy: It will support you to define taxonomies for terms defined in wp_terms.

wp_usermeta: This table contains meta-information about registered users.

wp_users: It contains user information, such as password, username, etc.

Conclusion

To sum up, we hope that you can find and replace text in WordPress Database easily thanks to this blog today. Moreover, if you think it is useful, why don’t you share it with your friends? Last but not least, don’t miss a good opportunity to get many Free WordPress Themes here.

5/5 - (2 votes)
Lt Digital Team (Content &Amp; Marketing)

Flash Sale Grab 25% Off for everything on today, don't miss it. Coupon code: FLASHSALE25 Redeem Now
Flash Sale Grab 25% Off for everything on today, don't miss it. Coupon code: FLASHSALE25 Redeem Now