There will come a time while using WordPress that you might need to get the Post ID, either for a plugin or perhaps you are a developer and need to query it. See the directions below on how to easily find the Post ID from within your WordPress dashboard and also with code.

Just like with your SSN, each page, post, and or custom post type in WordPress all have their own unique numeric post ID assigned to them in the database to identify them from one another. Behind the scenes, the post IDs are used by queries for all sorts of things.

How to Find The Post ID

When working with different WordPress themes and plugins, there will be times where they might ask for the Post ID. Usually, these are used to filter posts and or exclude them.  For example, the free Display Widgets plugin allows you to hide widgets on certain pages or posts based on categories, tags, etc. It also has an option to hide the widget based on a comma-separated list of post IDs.

Comma-separated by post ID

Comma-separated by post ID

To find the post ID you can click into the posts section of your WordPress dashboard and hover over the title of a post. In the bottom of your browser, you will see the post ID. In this example below, you can see the post ID is 5908.

wordpress get post id

WordPress get post ID

Another way to find it is to edit your post and the post ID will appear in your browser’s address bar. This same thing applies for pages, custom post types, etc.

post id address bar

Post ID in the address bar

Show Post IDs in WordPress Dashboard

When WordPress 2.5 was released, Post IDs were no longer shown in the dashboard. However, if you work with Post IDs a lot, there are some easy ways to re-enable that functionality. The first way to is to simply use a free plugin called Show IDs, developed by 99 Robots.

wordpress plugin show ids

Show IDs WordPress plugin

This plugin is super lightweight, only 3 KB to be exact, and doesn’t make any front-end calls. As of writing this, it currently has over 10,000 active installs with a 5 out of 5-star rating. You can download it from the WordPress repository or by searching for it within your WordPress dashboard under “Add New” plugins. There is nothing to configure, simply install, activate, and Post IDs will show in your dashboard. It also supports page IDs, category IDs, tag IDs, taxonomy IDs, etc. Below is an example of what you would then see.

show post id in wordpress dashboard

Show post ID in the WordPress dashboard

And if you don’t want to install another plugin, our friend Daniel Pataki also wrote a great tutorial on how to enable Post IDs in your WordPress dashboard with code.

Get Post ID Function

If you are a theme or plugin developer and are needing to query the Post ID, you can use the following functions. Use the following code within a loop to display the numeric ID of the current post.

If you are working outside of the loop, say in the footer. You cannot use the above function to get the post ID. Instead, you have to use the following:



function function_name() {
global $post;
$thePostID = $post->ID;

If you enjoyed this tutorial, then you’ll love our support. All Kinsta’s hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans


Please enter your comment!
Please enter your name here