Search and replace for multiple WordPress posts
One feature WordPress lacks is the facility to edit multiple posts at once. If you've changed your URL, for example, you'll be faced with editing dozens or even hundreds of hard-coded image tags in your posts. Moving domains from one host to another often causes WP to render single quotes as “ or â€~, and British pound signs as Á£ - editing all those by hand isn't a task I'd relish either.
Assuming your hosting provides access to your database through PHPMyAdmin or similar, editing multiple posts is easy. Sign into PHPMyAdmin, and find the table name which holds your blog posts; most likely this is wp_posts, but the wp_ prefix may be something else. Click the SQL button and enter the following:
UPDATE [wp_posts table] SET post_content = replace(post_content, "[old text]", "[replacement text]")
editing the square brackets and what's in them with your table name, old and replacement text strings. Remember, both the old text and the replacement text will need to be in quotes. If you want to get rid of some text but not replace it with anything, then leave the replacement text as just a pair of double quotes marks.
It would be remiss of me not to say that you should back up before you start messing about with PHPMyAdmin. But you're backing up your blog regularly anyway, right?
Posted by Sue on September 7, 2009 in WordPress.







