WordPress search and replace the easy way

How to quickly search and replace any HTML/text on a WordPress website

Got a client website that’s about to go out the door in the next 48 hours.

The site has got around 75 webpages, and noticed that the copy on one page needs to be duplicated to all other pages.   Arrrghh.  Now, we’re running a WordPress setup with multiple sites on all our servers (development, staging and live) and a lot of the WordPress search and replace plugins assume you only have one website/blog.

So … the easy way … stop searching for the perfect WordPress plugin and follow these simple steps -

  1. Pull up phpmyadmin
  2. Find the correct site/blog you’re wanting to update – in my case, it’s site # 16
  3. Go to the SQL tab and enter the following statement (where wp_16_posts uses the 16 corresponding with the correct site above!) -

    UPDATE wp_16_posts
    SET post_content = replace(post_content, "Old text here", "New text here")

  4. Now the nice thing is, the replace function can be built up of anything that’s in that post (or anywhere else in the database for that matter, but let’s keep it simple) … for instance -

    UPDATE wp_16_posts
    SET post_content = replace(post_content, "<h1>Dummy heading</h1>", concat("<h1>", post_title, "</h1>")

    … would take the post title, and replace the h1 Dummy heading text with the post title.

 

Hope that helps someone out there looking for a quick, down and dirty, search and replace for WordPress!

Mark

About Mark

Mark is the CEO of LogicSpot and loves his job. He still gets up every day and is happy to be in a career that he loves. From a young age he wasn't sure whether to go down the route of IT and software development, or art and design - both being his flair through schooling along with music. He chose the embodiment of both - designing beautiful websites and applications with his team that deliver beyond client expectations with finesse and grace

April 6th, 2011 / Tags: , , , , , , / Comments: 0

Leave a reply

Logged in as (Logout)

Twitter

One second…

From the blog

LogicSpot Awayday

So how did the dream team spend its awayday… Bowling at All Star Lanes.. (via the bar of course)   And so …

Read more

Sign up to our newsletter

Pop your email below to be kept in the loop about all things LogicSpot.