Search and Replace a Time Saver

This little plugin is always in my toolbox of “I don’t want to live without this” plugin.   I don’t use it often but when I do it is a dragon slayer.   Let me give you a couple of examples where this little tool shines and shows it’s stuff. Search and Replace.

Domain Name Changes and Site Migration

You are moving your blog from one domain to another.   Not too hard, right?   You do the backups the re-installs of the files, restore the database, change the domain name in the general settings and up pops the blog.   Cool.   Everything look like it is good and you take down the old site.   Suddenly all the images disappear from your posts.   Why?   Because the image url’s were still pointed to the old domain name.   They worked fine linking back to their original location till you took down the site.   What do you do?

Did you move the image files to the new site?   (Probably, let’s hope so)   You thought they were the ones being pulled into the new location.   But when you open a post in the editor, there is the link back to the old domain wp-content/upload etc.   Now the light comes on.   “Holy Kow, I have to change all the image links in all the posts to point to the new domain.

Senario 2

You built a new site “Off site” for a client.   Once they are happy with the way it looks you move all the files to their hosting, point the blog to their domain name and . . .   Same as above.   All the image links in the post/pages are back to your Development site.   What do you do now?

The answer is the same.   Use the plugin search and replace.   It will go through the database searching for the string to the old domain and replacing it with the new domain.   The plugin has the option to only search and replace in certain areas of the database.   Only need something in a post or page replaced?   check “content”.

For example:   You need to replace   with   Go to the search and replace settings page.   Select “Content” then enter in the search field and in the replace field.   Click “GO” and in about 1/10th of a second it is done.

Note: Make a backup of your database before using search and replace.

Removing Word Inserted Formatting

This past week I had a friend who set up a new site for a client.   The client had been writing all the content for the site in Word.   When the project was ready for content the client did a copy and paste move of all the content to the new pages for the site.

The content was all there, but the site was supposed to be justified so all the margins lined up right and left.   That’s how the Style.css was setup for the site.   The pages however were ragged right.   What happened?   Looking at the HTML editor revealed that every single paragraph for all the pages and post started with <p style text-align=”left”>   That line of html overrode the style.css.   My friend thought it was going to take going through the posts one at a time and removing the formatting code from each paragraph.

Enter search and replace.   Search: <p style text-align=”left”>   Replace: <p> .   Five seconds later the entire site was “justified”   and hours of tedious hand editing was avoided.

Put this Tool Away

Don’t leave this tool laying around.   Meaning, either don’t let anyone using the site know it exists, or better yet, when you are done using it, “DELETE IT” from the site.

Why?   because this can be a very dangerous tool.   If you are not careful you can end up changing text strings that you don’t want changed.

In the example above on domain name change.   If you have a post that references your old domain name and you spell it out; when the search and replace runs it will replace that string with the new one.   Therefore, you think carefully about the string you want to search and replace. In this example you could go further by searching for   and replace it with   This would prevent you changing any reference to just the old domain itself.

If someone sees this plugin and decides to use it for a quick way to change references or fix typo’s in a post, they could end up taking down the entire blog.

That is why it is good to only have it available on sites where no one can “stumbleupon” the plugin settings and try and use it.   I treat it like a powertool.   It works great, gets the job done fast, but shouldn’t be left where the “kids” might find it.


  1. Hi Dave,
    It’s so comforting to know you are slaving away at the lab trying out and teaching us new tricks! I do appreciate the work you do. Thanks!
    .-= Kristal Kraft´s last blog ..Homes for Sale in Denver Face Scams from Craigslist…Still. =-.

  2. KK,

    I do my best to help you find your “inner geek”.


  3. I wish I’d known about the Search and Replace plug-in when I began working on my Indianaolis, Indiana blogs. I could have used it to remove MSO Normal that was placed in hundreds of pages from writers using word to copy/paste their articles.

  4. Malita Jones says

    I have to bookmark this post and share it – where was this a couple of weeks ago when we were migrating our site – going from one wordpress site to another, codex anyone, it was a fun learning experience. Well there is tons to learn here – you’re a wealth of knowledge – thank you!
    .-= Malita Jones´s last blog ..4203 Duval St, Austin TX 78751 =-.

  5. My husband and I have had this problem with the style we choose not being there when we copy and paste. We will look at the html editor and take your advice.
    .-= Claire Gilbert´s last blog ..What Home Buyers Want in 2010 =-.

  6. Great advice, I use the Find and Replace feature in Excel frequently and it’s a huge timesaver. I’ll definitely keep this in mind when I have to do a find & replace in my blog – your examples really make it clear how this tool can be helpful. And yes, I too have fallen victim to copying & pasting from Word into WordPress only to find a huge jumble of unnecessary code that appears in the HTML window. Usually I try to paste into Notepad first and then into WordPress, so I just get the plain text.
    .-= Josh´s last blog ..Winnipeg Movers =-.

  7. You turned me on to this one many months ago. This plugin helps put together a city blog for PPC in not time at all.
    .-= Joe´s last blog ..Tri Cities Has Lowest Cost of Living in the State =-.

  8. Btw, I’m faceless! My gravatar is not displaying. 🙁 You can delete this comment if you like.
    .-= Joe´s last blog ..Tri Cities Has Lowest Cost of Living in the State =-.

  9. Joe,

    It is one of those tools that we don’t need very often but when we do it is a life/time saver.

    I’m faceless too.


  10. Hi Dave – It has been a while since I stopped in and said hello. I hope you are doing well. I am going to have to visit more often as I now have a Thesis WordPress blog:)
    .-= Bill Gassett´s last blog ..Staging and Preparing a Massachusetts Home For Sale =-.

  11. Bill,

    I’m afraid with Thesis you will find far few posts you can apply. Good luck with it.


    PS Glad you dropped by the Lab again.