Support » Plugins » Hacks » All GUIDs are the same since upgrading

  • I have a plugin which retrieve the GUID of a post

    $page_data = get_page( get_the_ID() );
    $link = $page_data->guid;

    This used to get a unique URL for each page – for example.

    Since I upgraded to WP 3.0, every GUID I retrieve is the same – that of the last post I made on the old version of WordPress.

    I can see in the database that there are unique GUIDs for each post but, for some reason, WP isn’t picking them up.

    Any idea how I fix this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • I’m having the same problem. It works fine for posts, but for pages the guid is always my home URL. This guy was having the same problem:

    Any ideas?

    Can’t see that problem myself so it must be due to placement of the code, or other code running prior to that code that’s changing the expected values of the necessary vars.

    Code was tested on my local installation and i received unique guids for each result shown.

    Is your code inside the loop?

    I am running into this as well. It has (in my case) nothing to do with the loop as yet, as the database itself is showing the base url for the site as the GUID for all my site’s pages. Except for one trashed page and I cannot get the GUID to update/stick on any other pages whether trashed, etc. (cannot recreate condition that will store correct GUID).

    Running WP 3.0.5. Will backup DB, upgrade and see if that helps at all.

    P.s. here’s the query to run to see what your page GUIDs are:

    , post_title
    , guid
    FROM wp_posts
    WHERE post_type = 'page'

    Since upgrading to 3.1, the problem has resolved for me.

    Actually you don’t even need the guid for getting a link to a post object, use get_permalink( $post_id ) instead

    You should NEVER, EVER use the GUID in your site. It is a globally unique identifier for RSS readers. RSS feeds use the GUID to know which posts have been published, so they don’t republish the same content over and over. It’s not a permalink (even though it looks like one) and due to inconsistencies in behaviour over the years its not even necessarily unique, so trying to use it within WordPress itself will cause a whole lot of pain.

    If you need to get an ID you need to use $post_id.

    at least in my case, Elpie, I was using it within an atom feed template.

    Word, thanks for the advice.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘All GUIDs are the same since upgrading’ is closed to new replies.