How to replace words in my posts and saved new words

For a one-time “patch” to update your database for word replacement, I find that this tool from interconnectit.com is excellent. Be sure to have a backup of your database first, just in case.

An alternative would be to write a plugin that pulls the content from each post, does the filter, then updates the post by saving it back to the database. Your code is only filtering the content when it is being displayed, you are missing the steps of actually modifying the content and saving it again.

The DB-level word replacement routine is much more efficient, especially if this is a one-time event. The tool will allow you to target specific tables, so you don’t inadvertently change text in other than the _posts table.