Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to do Search and Replace in WordPress with a Plugin

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Are you looking to do search and replace in WordPress? Recently, one of our users asked us how to run search and replace on WordPress database without writing any SQL code or using phpMyAdmin. Many beginners are not comfortable with code, so that’s why we found a search and replace plugin for WordPress. In this article, we will show you how to do search and replace in WordPress.

Search and replace text in WordPress database

Getting Started

It is extremely important that you create a complete WordPress backup before making any changes to your WordPress database.

Make this best practice a habit, things can go wrong anytime when you are making direct changes to the WordPress database. If you have a backup, then you can easily restore your WordPress site without losing anything.

Installing and Using Better Search and Replace for WordPress

First thing you need to do is install and activate the Better Search Replace plugin. Upon activation, you need to visit Tools » Better Search Replace page to use the plugin.

Better search replace plugin settings

Simply add the text string you want to search for and then add the replace text.

After that you need to select the tables you want to look into. For example, if you want to search and replace some text in your posts then you may want to select the posts table. You can also select multiple tables if you want.

Learn more about WordPress database management and what each table does in WordPress.

The plugin can run a case sensitive search and replace. It can also perform a dry run which allows you to see how many cells are affected by your search without actually replacing the text.

When you are satisfied, click on run search/replace button. If you did not check the dry run option, then the plugin will now run search and replace on your WordPress database.

Troubleshooting

You may see the white screen or run into timeouts while performing a search and replace. Simply click on the settings tab under the plugin page.

Troubleshooting timeouts during search and replace

You will notice the max page size option. Try decreasing the page size to avoid timeouts and white screen.

That’s all, we hope this article helped you find a better search and replace plugin for WordPress database. You may also want to see our tutorial on how to clean up your WordPress database for improved performance.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

24 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

    • WPBeginner Support says

      The plugin does have the ability to search what was added through other plugins, you would mainly want to make ensure you search the correct tables.

      Admin

  2. Paul G says

    Thanks, this mostly worked for me but didn’t quite change all of the image links.

    The rest I could easily change myself by editing the custom modules.

  3. Karol says

    Changed a website from http to https via cpanel; green lock did not appear and “connection is not secure” warning was present. This plugin worked great for me. The only difference I did was that I left the checkmark off “Case Insensitive?”.

    Every site can be different with it’s own hurdles to jump through but the dry run seemed to look okay without any errors so I ran with it. Green lock appeared right away for the site. Plugin worked for me. I hope it continues to work with other sites.

    My only question now is … Do I leave the Better Search Replace plugin installed and activated or do I uninstall it now that I’m done?

    • WPBeginner Support says

      That would be a personal preference question but you should be able to remove the plugin without worry :)

      Admin

  4. Mandy says

    Hello,

    My site is having issues showing images lately, and my host said that it’s because the paths are wrong. They recommended this plug in, but my problem is that I am not sure what I am searching and replacing. Here’s why:

    When I insert an image in “visual” mode within a post, it shows up. They all do.
    Then when I preview or publish, some images don’t show up. What I am noticing lately is that instead of the code showing them as “image.jpg”, they now have the image size you choose in the path – “image-300×188.jpg” (this happens to be the medium size for this particular image). Why is it putting the pixel dimensions? If none of the images worked, I could say yes, the paths are incorrect, but some images DO work! I am officially bamboozled. It seems so random.

    Best,

    Mandy

  5. Ashraf Ali says

    I am switching from http to https now the common problem faced is broken css, I am wondering if could use this plugin to replace https:// to just //

    So that all contents are delivered over https

    Cheers

  6. Drew says

    I had a program enter structured data that is all different. I want to remove everything between and including this : ———————-

    How would I do that?

    • WPBeginner Support says

      Hi Drew,

      We are not sure we completely understand your issue. However, we are guessing that you had a plugin to add structured data and now you want to remove the structured data from your WordPress posts and pages? If this is the case, then you can simply uninstall the plugin.

      Admin

  7. Sueli says

    Great plugin!

    I have a question.
    Can I use a wildcard?

    I am trying to remove numbers added after an image file. They are different (both the numbers and their length). The stop point would be the (“).

    Some examples of what I want to replace with (jpg”)
    (jpg?11906004322295206140″)
    (jpg?15231215847335105667″)
    (jpg?82668654789154738″)

    Is it possible with this plugin?

    Thanks

  8. David says

    I download “Better Search & Replace. Once it found entries, it doesn’t show me unless I buy premium addon.

    So instead I ditched that and downloaded “Search & Replace”. It took me only two minutes to replace 100 entries.

  9. Ralpheal says

    Wow thanks so much, this is truly a luxury. Going to save me a lot of time, as I was considering changing a phone number on 1oo’s of blog posts.

    Thanks so much, :)

    Ralpheal

  10. Mike says

    This plugin did not work for me. I backed up the database, then unchecked “Dry Run”. It messed up things all over the site and there was no way to undo the changes.

    I even tried to restore the database backup I created with it before making changes and that didn’t work. Don’t use this unless you’re prepared to do an entire site restoration.

  11. vikas kumar says

    sir
    help me out from pagination error i did which you show in video but i didn’t get result
    i am using macbook air in this your given shortcode not work properly

  12. Marko Tiosavljevic says

    yes, but this plugin is practically useless when it comes to migrations.

    When you migrate website from domain . com to another . com you need to change

    you need to connect to database for changing url or you need to insert it in wp_config as url

    i am working on external app wp safe mode that is solving this problems in best way.

  13. Nico says

    Hi, it seems that this plugin is no longer available in WordPress Plugin Directory. Which alternative plugin do you recommend?

    With kind regars,
    Nico.

  14. Brian says

    Does this take into account serialize data or will it break plugins that use serialized metadata? I know of a few plugins that do this for migration purposes. If it doesn’t it could cause more problems than it solves.

Leave a Reply to WPBeginner Support Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WPBeginner Assistant
How can I help you?

By chatting, you consent to this chat being stored according to our privacy policy and your email will be added to receive weekly WordPress tutorials from WPBeginner.