Support » Fixing WordPress » Need to do a global search and replace across all posts

  • Resolved tomhanna


    I have used WordPress for a couple of business sites (real estate) and because I’ve changed the company I’m licensed with I need to change the company name, phone number and my email address in all posts. Is there any way I can do this without going through post by post? Any possibility for doing a search and replace in the database directly? I have access to phpmyadmin and I could also download a database backup if there’s a Windows utility that would let me do this.

Viewing 7 replies - 1 through 7 (of 7 total)
  • I can’t think of a way to replace a string with another string directly via a query, so best to write a PHP script that grabs the post from the database, replaces any instances of foo with bar in the post, and then UPDATE‘s it.

    Can you handle that or do you need help?

    I’ll take a look at it and see if I can figure it out. Thanks for the reference.

    Well, of course trying to figure out how to do that I ran across this function that worked just fine in phpMyAdmin:

    UPDATE wp_posts SET post_content=REPLACE(post_content, ‘xyz’, ‘abc’);

    Tested it on one blog and it worked just fine.

    Oh, awesome. *gives a thumbs up and makes a mental note that there is REPLACE in MySQL*

    Or if you don’t want to write query strings, then export wp_posts from phpMyAdmin, edit it as a text file someplace where you can see exactly what you are doing and can’t break your blog, and then re-import.

    i am sure i saw a plugin which did just that on the wordpress codex.

    Hi, I’m looking to do the exact same thing here, using megarva’s solution. A little new to phpMyAdmin, though. How do I do the re-import? Thanks for the help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Need to do a global search and replace across all posts’ is closed to new replies.