Title: Changing String in All Posts
Last modified: August 18, 2016

---

# Changing String in All Posts

 *  [ashes999](https://wordpress.org/support/users/ashes999/)
 * (@ashes999)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/changing-string-in-all-posts/)
 * If I have a string in multiple posts–say the string “ABCDEFG”, is there a way
   that I can do a post-wide search-and replace, to replace it with something else?
 * If yes, then can this also be done at the HTML level?

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [katesgasis](https://wordpress.org/support/users/katesgasis/)
 * (@katesgasis)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/changing-string-in-all-posts/#post-372154)
 * You need to have a plugin to do that. Use regular expression to loop over the
   posts in a function called by a post_content hook.
 *  [davidchait](https://wordpress.org/support/users/davidchait/)
 * (@davidchait)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/changing-string-in-all-posts/#post-372162)
 * try searching on search and replace. I think this has been discussed before. 
   you sound like you want a one-shot update of content, not a plugin that converts
   every time the content is loaded.
 * -d
 *  [aleister](https://wordpress.org/support/users/aleister/)
 * (@aleister)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/changing-string-in-all-posts/#post-372166)
 * Here is a basic plugin:
 * `<?php
    /* Plugin Name: Plugin name goes here Plugin URI: The plugin's URI goes
   here Description: Description goes here Author: Name goes here Version: Version
   goes here Author URI: Your URI goes here */
 * function replace_text_in_posts($content) {
 *  return str_replace("text to find", "text to replace it with", $content);
    }
 * add_filter('the_content', 'replace_text_in_posts');
 * ?>
 * But yes, as davidchait mentioned, if this is simply a one time thing, you could
   always do something like an SQL query to replace the text.
 *  Thread Starter [ashes999](https://wordpress.org/support/users/ashes999/)
 * (@ashes999)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/changing-string-in-all-posts/#post-372252)
 * Yes, I’m looking for a one-shot change. Is there a simple way to do it? If not,
   I can probably figure out an SQL statement that’ll cover the changes for me.
 * Something like:
 * UPDATE wp_posts SET post_content <something> WHERE post_content LIKE (SELECT 
   post_content FROM wp_posts WHERE post_content LIKE <search string>)
 *  [Chris_K](https://wordpress.org/support/users/handysolo/)
 * (@handysolo)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/changing-string-in-all-posts/#post-372253)
 * You saw the post immediately above yours?
 *  Thread Starter [ashes999](https://wordpress.org/support/users/ashes999/)
 * (@ashes999)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/changing-string-in-all-posts/#post-372254)
 * Yep. Not bad for dynamic search/replace, but not what I want.
 *  [aleister](https://wordpress.org/support/users/aleister/)
 * (@aleister)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/changing-string-in-all-posts/#post-372261)
 * After a bit of searching, I found this plugin:
 * [http://thedeadone.net/?p=183](http://thedeadone.net/?p=183)
 * It gives you a new panel, with ‘search and replace’, and will go through and 
   do an SQL replace of text.
 * It is a plugin, but not in the sense that it will execute on all posts. It simply
   gives you a form in your admin panel which lets you do a SQL search and replace.
   It does not need to run on all posts because it does it directly to the database.
 * I will have to add this to my list of useful plugins 🙂
 *  Thread Starter [ashes999](https://wordpress.org/support/users/ashes999/)
 * (@ashes999)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/changing-string-in-all-posts/#post-372263)
 * Thanks, that’s positively brilliant 🙂

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Changing String in All Posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 5 participants
 * Last reply from: [ashes999](https://wordpress.org/support/users/ashes999/)
 * Last activity: [20 years, 2 months ago](https://wordpress.org/support/topic/changing-string-in-all-posts/#post-372263)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
