WordPress.org

Ready to get started?Download WordPress

Forums

Site-wide string search/replace (6 posts)

  1. HeroOfSpielburg
    Member
    Posted 7 years ago #

    Hello,

    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
    Member
    Posted 7 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
    Member
    Posted 7 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.

    Thanks.

  4. 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
    Member
    Posted 7 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
    Member
    Posted 7 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