WordPress.org

Ready to get started?Download WordPress

Forums

All GUIDs are the same since upgrading (9 posts)

  1. edent
    Member
    Posted 3 years ago #

    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 - http://shkspr.mobi/blog/?p=2333 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?

  2. Laura McDonald
    Member
    Posted 3 years ago #

    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:
    http://wordpress.org/support/topic/field-guid-is-not-being-saved-for-new-pages?replies=1

    Any ideas?

  3. Mark / t31os
    Moderator
    Posted 3 years ago #

    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?

  4. mahalie
    Member
    Posted 3 years ago #

    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:

    SELECT ID
    , post_title
    , guid
    FROM wp_posts
    WHERE post_type = 'page'
  5. Laura McDonald
    Member
    Posted 3 years ago #

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

  6. felipelavinz
    Member
    Posted 3 years ago #

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

  7. Elpie
    Member
    Posted 3 years ago #

    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.

  8. Laura McDonald
    Member
    Posted 3 years ago #

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

  9. mahalie
    Member
    Posted 3 years ago #

    Word, thanks for the advice.

Topic Closed

This topic has been closed to new replies.

About this Topic