WordPress Post GUIDs: Sometimes You Should Update Them

Vega, snowflake desktop wallpaper by Alexey Kljatov. CC BY-NC 2.0

TL;DR — Updating the GUIDs of a WordPress site that’s already live will annoy people subscribed to its RSS feeds. But if the site has never been live, you should update the GUIDs.

What is a GUID?

GUID is an acronym for Globally Unique Identifier. It is a concept that goes well beyond WordPress and is used in all kinds of applications. In the past, I used GUIDs heavily working with ASP.NET and Microsoft SQL Server for example. Those GUIDs looked like this:

6F9619FF-8B86-D011-B42D-00C04FC964FF

(I know, shocking right! A Microsoft stack, really dude? If it’s any consolation, I hated every minute of it.)

RSS feeds are another example that employ GUIDs. Every item in an RSS feed can have a <guid> element.

How does WordPress use GUIDs?

WordPress employs GUIDs when it generates its RSS (and Atom) feeds. If you take a look at the RSS feed of this blog you will see elements similar to this:

<guid isPermaLink="false">https://deliciousbrains.com/?p=6806</guid>

WordPress uses a real, working post URL as the GUID. In fact, if you go to the URL in the example above, it will redirect you to the blog post it belongs to. This is also the URL the post has when using the default Permalink setting. Since URLs are globally unique by their nature, they make pretty good GUIDs so long as they don’t change. And in this case, since we’re using the post ID in the URL, it’s almost certain not to change. A good design decision.

What are GUIDs used for in RSS feeds?

RSS feed readers (e.g. Feedly) use GUIDs to uniquely identify an item against all other items that have appeared in the feed and will appear in the future. It uses the GUID to determine if it should show an item as new.

The GUID is supposed to be the constant. Other details of the post may change, like the title, content, URL, dates, etc but so long as the GUID stays the same, the feed reader can avoid showing the same item twice.

For example, let’s say we update the URL of one of our posts from

https://deliciousbrains.com/tour-of-the-wordpress-database/

to

https://deliciousbrains.com/tour-wordpress-database/

If the RSS feed was just looking at the URL, it would see two posts and show two items with the same title and content in the reader. But since it looks at the GUID and the GUID hasn’t changed, it knows that it’s the same post.

Why would I change the GUIDs?

Accidentally. You might not realize you have.

People often tell me they don’t need WP Migrate DB. When they need to migrate a site from one domain to another, they just dump their database to an SQL file, open it in a text editor, and run a find & replace.

There are several reasons I don’t recommend this, but let’s focus on GUIDs. We’ve already established that WordPress uses URLs for GUIDs. Therefore, doing a domain find & replace on an SQL file will almost certainly change the GUIDs.

And if you change the GUIDs, all of the posts in your RSS feed will show up as new posts in your subscribers’ feed reader, annoying them at best and certainly giving them a reason to unsubscribe.

Should you ever change GUIDs?

Yes, there are some cases when you probably should update the GUIDs. For example, if you’re migrating from a dev or staging site to live and the site has never been live before. You don’t really want your GUIDs to be a dev or staging URL. It probably wouldn’t hurt anything, but it certainly isn’t reassuring to see dev and staging URLs in a live database.

That’s why we give you the option in WP Migrate DB (and Pro) to replace GUIDs or not:

Screen Shot 2015-03-01 at 4.30.01 PM

How do you make sure that your GUIDs are updated only when they should be? Do you use WP Migrate DB? Did you know about this feature?

About the Author

Brad Touesnard

As founder of Delicious Brains Inc., Brad wears many hats; from coding and design, to marketing and partnerships. Before starting Delicious Brains, Brad was a busy freelance web developer, specializing in front-end development.

  • Andy

    Good to know, Brad! I appreciate your help. Your expertise has become one of my go-to resources when migrating WP sites.

  • Wow this is worth knowing! thanks for the info, will be more careful about this in future

  • Maks Sherstobitow

    Thank you, very useful.

  • Great outline! Really helpful for anyone new-ish to WordPress. 🙂

  • Great ! And highest professional as ever.
    Now I know what GUIGs are for after 5 years of using WP. Thanks.

  • Tim Rourke

    Awesome article. I’ve been bitten in the past by not updating GUIDs for images. Ocasionally, I want to grab the ID of a media upload by it’s URL. For example, I might have a custom field somewhere that stores an image as its URL string, for interpolation into a template.

    So far, the way I go about this is use a function similar to the ones described in this thread: https://wordpress.org/support/topic/need-to-get-attachment-id-by-image-url

    What I did not know was that this approach relies on the URL of the image matching the GUID, which isn’t always the case if you’ve already moved your development site around a few times, perhaps from your local machine, to a staging server, then to production.

    Takeaway: GUID = “Gotta Understand It, Dude” 🙂

  • harishchouhan

    Thanks Brad. new knew about the RSS issue with GUID until now.

  • Daron Spence

    So what about this scenario:

    i have a dev site at dev.example.com currently running while doing a redesign

    When I want to push to example.com for the launch, I replace GUIDs right?

    Then if I have to do more changes, I pull from example.com and don’t replace GUIDs? Or change them on both?

    Cheers! Great article otherwise, and a great product 🙂

    • So long as you don’t push to example.com again, it really doesn’t really matter if you replace GUIDs when pulling to dev.example.com. And we don’t recommend pushing to example.com after it’s been launched as any changes occurring on that site since you last pulled into dev will be lost. Instead, we recommend this strategy: https://deliciousbrains.com/avoiding-wordpress-database-merging/

  • Thanks for this explanation.

    I have an issue with exporting and importing pages.
    On my DEV site, I created a new set of pages and exported them using the build-in WordPress Exporter plugin.
    On my PROD site, I uploaded the pages using the build-in Importer plugin.
    The PROD site was already live for some time. And now it seems that my imported pages have the GUID of the DEV site…

    Any suggestions on how to fix these?

    Thanks!

  • Very well explained. All in all, very helpful post.

  • I tried the WP Migrate DB plugin after fumbling around clumsily with Search and Replace and found it a damn pleasure to use. My GUIDs were updated flawlessly even on partial strings.

  • Michael Kammes

    Is there a way to change a single GUID? Thus far, it seems to be a global change as opposed to a one-off.

    • You can manually edit your database if you want to change just one GUID. Out of curiosity, why do you need to update a single GUID?

      • Michael Kammes

        Thoughtlessly duplicated an existing post twice (and thus appending the GUID to “pagename copy”, then altered each post for it’s intended need. This generated 2 posts with the same GUIDs, which is causing issues with RSS feeds for iTunes and GooglePlay.

      • Michael Kammes

        Have a recommendation for a plug-in to edit in place?