Replacing strings in old WP posts

After trying several different methods of including photos in posts I had images scattered in several folders and links pointing all over the place. I could have just left the old stuff in place, but that offended some silly aesthetic sense. So, I wanted all of the image references and links in the old posts replaced with the new stuff.

Unfortunately, WordPress doesn’t have a built-in tool to find and replace strings in old posts, probably a good thing due to the potential for disastrous user error. There are some plugins that filter the text in posts, for instance to censor posts or to expand shorthand, but nothing to change old posts directly. Finally, I found this thread at with a discussion of how to do exactly what I wanted to do. Feeding this SQL snippet to PHPMyAdmin worked perfectly:

UPDATE wp_posts SET post_content= REPLACE (post_content,'old string','new string') WHERE post_content LIKE '%old string%' ;

Avatar photo

By isaac

I like cats. he/him