visitor stats

How to Search and Replace Wordpress In Blog Post

wordpress

Sometimes situations like the following leave you no choice but to undergo a find and replace to fix the problem.

  • Weird characters in blog entries after upgrade. After performing a wordpress upgrade, some characters will appear as "” Â", "’", "??"
  • Rename keyword1 to keyword2. You want to rename keyword1 in your entire database to keyword2, but opening the 100Mb database file with your text editor is not the smartest idea. After all, you’ll need to download a file as big as100Mb down before you can start changing, upload it before you can preview.
  • You discovered a typo. You been using this phrase all the while and just realized it was wrongly spelled and want to search and replace all blog contents containing this typo.
  • More?

Here’s few methods I’ve been using to mass find and replace in Wordpress blog entries. And like always, please backup any files that you intent to change to avoid data lose.

Search and Replace with Wordpress Plugin

wordpress find and replace

This plugin provides you with an interface in WP-Admin to search and replace text across all blog post. All you need to do is download, install the plugin and you are ready to go.

Download Search and Replace.

MySQL Search and Replace with PhpMyAdmin

This requires you to have access to your PhpMyAdmin. If you are using this method, I’m assuming you are pretty familiar with how PhpMyAdmin works; if you are not DO NOT USE THIS METHOD. Backup your database before proceed.

  1. Open up your database in PhpMyAdmin.
  2. Most of the time, you’ll want to change the contents so we’ll use "wp_post" table and "post_content" field as an example here. Click on the SQL tab.

    sql tab

  3. Here’s the quote you should paste into the textarea.

    UPDATE wp_posts SET post_content = REPLACE (
    post_content,
    ‘Item to replace here’,
    ‘Replacement text here’);

    Make sure all text are in between the quotes . Double check before you hit the GO button.

So when you hit the GO button, it will go through post_content field under wp_post table, looking for all/any ‘Item to replace here‘ and replace them with ‘Replacement text here‘.

Related Contents

Sponsors

Posted by hongkiat in Wordpress, Wordpress Plugin, Wordpress Tips Tricks , at 12.31.07

Tags: , , ,

Comments

  1. uzairubiah December 31st, 2007

    That’s a good article you provide.I seldomly use to see those errors like that before.

    Reply
  2. Syahid A. December 31st, 2007

    A very nice Wordpress function indeed.

    Reply
  3. Sly from Slyvisions.com January 1st, 2008

    I’ve been looking all over the internet for this. Thanks for sharing us the plugin!

    Reply
  4. jocuri June 28th, 2008

    hey really great stuff , thankx so much !

    Reply

Leave a reply