Ever wondered what the GUID Field is for in your WordPress database? Read on to find out!
What is a GUID?
A UUID (Universally Unique ID) is an algorithm-generated 128-bit unique number that can be used to identify different software or hardware without worrying about duplicates.
The term GUID comes from “Globally Unique Identifier” and it is a type of UUID identifier, design for the same purpose.
In the related RFC document, several types of GUID are introduced. Usually, it is in a string format of alphanumeric characters, that is attached to one thing only and it does not change.
GUID in WordPress
Atom and RSS feeds also contain unique identifiers for each blog post when rendering a website content.
WordPress also uses its own GUIDs to successfully check whether or not a particular item has displayed before.
It was decided that in WordPress the GUID format will be a URL, like these examples you can see in the posts database table
https://www.mydomain.com/?p=1
https://www.mydomain.com/?page_id=3
https://www.mydomain.com/wp-content/uploads/2019/02/proionta-sustimata-asfaleias.png
This seemed like a good and practical idea, as the URLs are already unique.
Let’s take a look at this feed https://pressidium.com/blog/feed/ for example.
Inside each item element you will notice this type of information
<guid isPermaLink=”false”>https://pressidium.com/?p=41029</guid>
This is the GUID element we are talking about. It is structured by the domain and a query string for the post id that is of course the post corresponding id in the id column of the posts database table.
So what happens is that in combining those two parameters, WordPress creates values that cannot be repeated through the entire internet and therefore can be safely used as GUIDs.
Even if the URL changes for any reason, for example when the site moves to a subdirectory or migrates and changes domain, or the permalinks settings change, these identifiers will not. They may look like a URL but they are not used like one. And this happens for a specific reason.
Why Identifiers Don’t Change
The GUID element is used by the RSS feed readers to distinguish a post. The post’s friendly URL could be changed for several reasons by an admin user and this change should not interfere with the RSS feed and here is why.
Let’s say a post URL changes from:
https://mydomain.com/my-services/
to:
https://mydomain.com/my-unique-services/
If the GUID also changes upon this modification, then the reader will read two versions of the same post content.
Try our Award-Winning WordPress Hosting today!
A classic scenario where this mistake occurs is when a website is migrated between servers. During a migration you have to replace the old domain with the new one. If you search-replace the URLs in the database without excluding the GUIDs, then the RSS readers will display your old content as new content and this may confuse your visitors.
When You Could Change the GUIDs
WordPress strongly recommends against changing GUIDs by saying “When changing the URLs directly in the database, you will come across instances of the URL being located in the “guid” column in the wp_posts tables. It is critical that you do NOT change the contents of this field. ”
But here is an exception to the rule.
If you are done with building your website locally or in a staging environment and you are about to go live for the first time, then changing GUIDs is maybe the right choice.
No matter if you are coming from a local or a staging environment, when going to production for the first time, you do not want to include random URLs in your GUIDs like the ones a testing environment might generate like the plesk preview URL for example.
The post ids though remain the same in the new environment and should not be changed for any reason.
Change with a Plugin
The wisest thing to do in case you want to replace the guid column is to do it via a plugin.
WP Migrate DB is a safe way to go as it has a pretty straightforward interface. Once you install and activate it, you can easily find the related checkbox under the Tools -> Migrate DB menu item and choose whether or not you want to replace GUIDs while migrating your database.
As we already explained, if you are already on a live site, you should leave this unchecked.
Conclusion
We hope that we helped you become familiar with the GUIDs, their purpose and how WordPress handles them. Despite the exceptions, keep in mind as a guide that GUIDs should not change no matter the modification in the URL of the post, and if so, you should avoid doing it manually.
Start Your 14 Day Free Trial
Try our award winning WordPress Hosting!