Are Post IDs Unique Across all Post Types?

I thought WordPress post IDs were only unique within each post type, so that the first instance of each post type would have an ID of 1 and they would count up from there. In order to get a specific instance of a custom post type, you would have to designate that post type in the query.

But according to this answer on another question, post IDs are actually unique to each post, regardless of post type. I checked in the posts table for the site I’m working on now, and sure enough the post IDs are unique. But I’m sure I read somewhere (a couple years ago) that they weren’t.

Did WordPress change the way it sets post IDs, or have I just been wrong this whole time?

1 Answer
1

All post types are stored in the same posts table, so they have to use different post IDs. That was always the case, since the the post type page was introduced 2005 with version 1.5.

Leave a Comment