WordPress Search and Replace Plugin

So a few weeks ago I made a change to my site on how the permalinks were displayed. A permalink is a link that you can use permanently to link to one of my posts. So if you wanted to say “Look at what this idiot Stu said about Democracy” on your blog and link to a post that I had written rather than the main page, which changes, you’d link to a permalink of mine.

The permalinks had previously been displayed as: http://www.fourmajor.com/?p=291

I changed it to: http://www.fourmajor.com/index.php/2007/04/24/heartbreaking-update-on-the-legless-man/

When I put an image into one of my posts (such as a picture or a screenshot), I would write the HTML like this: img src=”images/image.jpg” That way, if I ever changed the name of my website to, say, bestwebsiteever.com, I wouldn’t have to change any of my image tags. Well, when I changed my permalink structure, all this got broken. Instead of looking for fourmajor.com/images/image.jpg, my web server was looking for fourmajor.com/index.php/2007/04/24/images/image.jpg. This obviously wasn’t going to work. I figured there had to be a better way…

Thankfully, there is. What I did was to download this nifty search and replace plugin. I replaced all instances of “images/” with “http://www.fourmajor.com/images/”. This way, I can use the permalink format that I like. And should I ever change my domain name, I can simply do another search and replace. Oh, and for good measure: w00t.

Post Revisions:

There are no revisions for this post.

Comments

2 responses to “WordPress Search and Replace Plugin”

  1. greg Avatar
    greg

    That’s kind of a neat plugin, but you might be going about solving this problem the wrong way. If you want to make your links (to images or internal pages) domain-proof without having to grep the old ones out every time, you can just do what you did before, but add a leading slash:

    EG, “/images/foo.jpg” will point to “www.bar.com/images/foo.jpg” for all values of bar.

    The permalinks are sweet, though. I’ve wrangled with mod_rewrite enough to really appreciate that WordPress makes them so easy.

  2. FourMajor Avatar

    Oh. Nice. Good tip. I didn’t even think of that.