Site-wide string search/replace (6 posts)

  1. HeroOfSpielburg
    Posted 9 years ago #


    I'm new to the database paradigm for blogging, so please excuse the ignorance of my question.

    Does anyone know a way to do a site-wide search and replace for a string? For example, go through all posts, find "http://mysite.com/blah" and change to "/bleh".

    Thanks for the help!

  2. drmike
    Posted 9 years ago #

    Why not just export out the database, run a search and replace using a text editor like Ultraedit, and reimport it?

  3. HeroOfSpielburg
    Posted 9 years ago #

    I suppose that may be what I'll have to do. I've never opened up a SQL db before, and I was a little leery of doing so and then reintegrating it to WordPress.

    I was hoping there was already some kind of WP-side interface for something like this, but I guess I have to jump and make it happen.


  4. Les Bessant
    keeper of the Tiggers
    Posted 9 years ago #

    There is a Search and Replace Plugin, which does direct database updates.

    I've used it a couple of times, and it does what it says it will. As with anything that can make major changes, make sure you have a backup of your database first.

  5. jabash
    Posted 9 years ago #

    I have the same issue and S and R pluging does not do it for me. For one thing it is all in German. I tried just doing a search without replace and didn't get any hits.

    I am moving my images to a Gallery 2 system and need to change the photo links in the posts.

    Any other suggestions?

  6. Pizdin Dim
    Posted 9 years ago #

    This SQL update query will work, assuming your table is called "wp_posts", the old string is "http://mysite.com/blah" and the new string is "/bleh":

    update wp_posts set post_content = replace(post_content, 'http://mysite.com/blah', '/bleh');

    You will need the MySQL client tool or something like phpmyadmin.

Topic Closed

This topic has been closed to new replies.

About this Topic