Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have some texts that need to be replaced in every posts in my blog. Is it possible to do that?

ps (I need to tag this question as search-and-replace but not enough reputation to do that. Please add the tag if you can. Thank you!)

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You have at least three different ways:

1) Edit directly in the database. The content of the post is stored in post_content column of wp_posts table. Since you are running your own WordPress, you should have full access to that. Just use SQL to do search and replace. Remember, the table content is sort-of HTML, so may have tags and/or escaped characters

2) Export your blog into XML, do search/replace in any UNICODE ready editor and import it back in after deleting original content. I would practice this a couple of times first though, especially checking what happens with images, etc.

3) Use WordPress remote access API to iterate through posts and update them that way. Good for programmers and/or more flexible way of doing things, such as content-specific updates.

share|improve this answer
    
In the title is specified that this is on WordPress.com, not a self-hosted blog, so your first suggestion won't work here. The XML-RPC way is interesting! –  Jan Fabry Jan 4 '11 at 16:40
    
Thanks. I flipped them in my mind obviously. –  Alexandre Rafalovitch Jan 4 '11 at 17:16
    
@Rafalovitch Your #2 suggestion: Deleting the original posts will make my blog lose the original created date of the post and I don't think I want to do that. –  Nam G. VU Jan 5 '11 at 3:58
    
@Rafalovitch I'm a developer and love to try your #3 solution. Thank you! –  Nam G. VU Jan 5 '11 at 3:59
    
@nam-gi-vu, I think if you export and import WordPress-specific XML format you can preserve the dates. It's been a while since I tested though. And of course, option 3 is more fun. –  Alexandre Rafalovitch Jan 5 '11 at 20:43
add comment

Hi @Nam Gi VU:

I'm pretty sure that's not possible directly.

What you could do would be to export all posts to a text file, use a search and replace in a text editor and then import them back in deleting all the posts before you reimport them. Be careful to change a copy of the export in case your search and replace corrupts the file and makes it fail to import.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.