There are many cases where you may need to find a page ID or post ID in WordPress. For example, you may need to provide specific post IDs in the settings for a plugin, or you may need to reference a post in your template files.
Unfortunately, WordPress doesn’t make this as obvious as it could be—so in this tutorial we’ll cover exactly how to find the ID of a page or post.
What Are WordPress Post IDs?
Every piece of content in WordPress has a unique numerical ID. This includes posts, pages, media attachments, categories, tags, and custom post types.
Whenever WordPress needs to serve up a piece of content, it uses the post ID to query the database for the content and related metadata.
Here’s what that looks like in the database:
This unique identifier is important because it’s static. Post titles may change; slugs may change—but post IDs never change.
This is why plugins that need to include or exclude posts (e.g. a related posts plugin or a social sharing plugin) will often ask you for specific post IDs.
But how do you find a post ID in the WordPress dashboard?
How To Find A Post ID Or Page ID In WordPress
Finding a WordPress page ID or post ID is pretty simple, though it’s a little unintuitive.
When you edit a post or page in WordPress, the post ID number will appear in the URL:
post=NUMBER in the URL. That number is your post ID.
The same principle applies to pages:
How To Find A Category ID Or Tag ID In WordPress
Unsurprisingly, you can follow a similar process for other types of WordPress content.
For taxonomies such as categories and tags, open the taxonomy list by going to
Posts > Categories or
Posts > Tags, then click “Edit” near the category/tag you want to identify.
Once again, you’ll want to look to the URL. For taxonomies, you’re looking for a string like
tag_ID=NUMBER. That number is the ID of your category/tag.
How To Find A Media Attachment ID In WordPress
To find the ID of an image or other media attachment in WordPress, go to
Media > Library in your dashboard, locate the item you want to identify, and click on it.
This will bring up the “Attachment Details” screen.
Once again, you can find the ID in the URL. For media attachments, it will appear as
item=NUMBER. That number is the media ID.
How To Show Post IDs In Your WordPress Dashboard
If you need to view the IDs of your WordPress content regularly, you probably want a more efficient and user-friendly solution.
If that’s you, I recommend that you install the free Reveal IDs plugin, which adds a new ID column to the WordPress “edit” interface.
This makes your IDs easily accessible for posts, pages, categories, tags, and custom post types.
If you want to hide this column for a particular post type, simply open the “Screen Options” menu and uncheck “ID” from the list:
Knowing how to find a post ID or page ID in WordPress can really come in handy when you need to reference specific content on your site.
While using the URL trick can get the job done, you may want to install the Reveal IDs plugin if you need easier or more frequent access to your post IDs.
In any case, if you have any questions about WordPress post IDs, please feel free to leave them in the comments below!