When using WordPress, there may be a time when a plugin will ask you for a post ID. How do you find post ID in WordPress (WP)?
The post ID is not something that everyone will need to know, however you might need to know where to find the post ID if a plugin asks for it. A plugin would need the post ID to filter posts. For example, the free Display Widgets plugin lets you hide widgets on pages or posts based on categories or tags. Also, WP themes may also ask for post IDs during configuration.
Where to find the post ID in WordPress
The best way to find a post ID is from the All Posts screen. This can be found by logging into the WordPress dashboard and clicking Posts > All Posts. Then you move your mouse over what you want to find the ID for and look down at the bottom left-hand corner of the screen. The pop-up box that appears will contain the post ID. More specifically, the post ID is the number that comes after the “post=” and before the “&“.
Another way to find the post ID is in the WordPress editor. All you have to do is click on the post that you want and you will find the post ID in the address bar. The URL shown will be exactly the same, and the post ID is found between the “post=” and the “&.” Each of these methods are easy and won’t take more than a couple of seconds to find the post ID.
Still there are other aspects to WP that will have a custom ID number. Every WP page, category, tag, etc., on your site will have a unique ID number. To find these ID numbers, you just have to follow the methods above. For example, when looking for a category ID, click Posts > Categories from within the WP dashboard. When there, hover over the category you are seeking, and you’ll find the URL you want in the bottom left corner. The category ID is found after “category&tag_ID=” and before “&” as seen in the screen grab above.
Show Post IDs in WordPress Dashboard
When WordPress 2.5 was released, Post IDs were no longer shown in the dashboard. But if you work with Post IDs often, there are methods to re-enable that functionality. The first way to is to simply use a free plugin called Show IDs.
Show IDs WordPress plugin
This plugin is super lightweight and doesn’t make any front-end calls. As of July 2018, the plugin has over 10,000 active installs with a high rating of 5 out of 5-stars. It can be downloaded from the WP repository or by searching for it within your WP dashboard under “Add New” plugins. Then simply install, activate, and post IDs will appear in your dashboard.
Get Post ID Function
If you are a theme or plugin developer, you can use the following functions to query post ID. Use the following code within a loop to display the numeric ID of the current post.
<?php the_ID(); ?>