Are post ID’s reliable?

The pedantic answer is NO.

While IDs are unique they can change without any change in UX as long as the change retains the consistency of the DB. And while creating a new post will generate a new unique ID, you can also create a post via code to reuse some “old” ID.

In practice they are reliable, but if reliability is very important to you then you need to attach some data to the post which will be used as the reliable identifier for your own needs.

Update: totally forgot about it because it is rarely used, and most of the time I seen it used it was used incorrectly, but wordpress has a reliable unique identifier by definition and it is the GUID

Leave a Comment