Problem with guids and absolute links

Post and page guids include the full absolute URL of my site (e.g. http://www.example.com/wordpress/?p=1). This causes a problem if the domain, or wordpress path changes, or if I’m viewing the site via its IP address rather its domain, etc.

Problem 1: there are some internal links on my site that are using the guid. I’m guessing this is wrong and I should rewrite the template code to remove references to the guid – correct?

Problem 2: images are inserted into a post using their absolute URL, rather than a relative one. This seems short-sighted, but I’m wondering if there’s a reasonable reason for that. Is there a way to change that behaviour?

4 s
4

1) The GUID is exactly that — a GUID. It’s used to uniquely identify the post. If you need to link to a post, then use get_permalink( $post_ID ) ($post_ID is optional) (link: get_permalink).

2) Not without a plugin, no. There’s talk of using an image shortcode for 3.1 though, or maybe 3.2.

In the meantime, you can try using an alpha version of my Regenerate Thumbnails plugin:

http://viper007bond.pastebin.com/XprbYtg2

It’ll go through all of your posts and update all image tags.

Make sure you back up your database first though. The code is alpha and not guaranteed to work, although I have tested it quite a bit.

Leave a Comment