How to Find the Post ID in WordPress

How to Find the Post ID in WordPress

Updated on Feb 28, 2020

Every page, post, and custom post type in WordPress have a unique number (ID) generated by the WordPress system in the database. A Post ID will often be required from some plugins, custom apps, or a code snippet. The whole process is not difficult at all, but in case you need some assistance, this guide is precisely to help you find that WordPress post ID, providing you with different options to do that.

In this post, you will find:

Why Do I Need the Post ID?

One of the main reasons you would need to know a specific Post ID is when themes or plugins ask you about it. Plugins and themes that require such information are usually those that filter posts in one way or another. 

The Post ID can play an essential part in configuring some plugins in WordPress. If you know the ID number of every post, you will be able to make some specific exceptions or manage individual posts separately from others.

How to Find the WordPress Post ID Manually

The easiest method to find a post ID is done right within the WordPress Dashboard. Once you are there, navigate to PostsAll Posts. Then hover over any of the post titles you wish to identify. You will see a URL preview on the bottom left corner of your browser window. More specifically, the post ID is only the number that comes after the “post=” and before the “&“:

Find Post ID by Hovering Over a Post

You can also see the Post ID while you’re editing it. Just take a look over at the browser’s address bar. Again, the post ID is only the number placed between the “post=” and the “&“:

Find Post ID in Browser Bar

The method is also applicable to pages, custom post types, etc. 

How to Show a WordPress Post ID in WordPress with Plugin

After the release of WordPress 2.5, Post IDs shown by default in the dashboard were discontinued. There are WordPress plugins that can assist when looking for specific IDs. Such plugins can prove quite useful, especially if you need to search for multiple IDs from various posts. So, in case you work with your Post IDs often and want them to be easily seen with a glance, you can do that. Three of the most popular plugins that can help you here are Show IDs, Show Pages ID, and Reveal ID.

Show IDs

This plugin is free to use, developed by 99 Robots. With it, you will be able to see the post IDs as seen in the screenshot below:

WordPress Showing Post IDs Via Show IDs Plugin

Show IDs is only 3 KB. Frankly, if you had it from the beginning, you would not think of it as a plugin, but just as a part of WordPress. The plugin currently has more than 10k active installs and a 5-star rating. It’s available on the WordPress repository or when you search for it in your WordPress dashboard.

You don’t need to configure anything. All you have to do is simply install and activate it. In addition to the post IDs, you will be able to see page IDs, category IDs, tag IDs, etc.

Show Pages ID

Developed by YYDevelopment, Show Pages ID is an open-source plugin that enables users to view all types of WordPress IDs, which are visible in the WordPress admin area.

Reveal IDs

Another excellent plugin for finding WordPress IDs is Reveal IDs. With similar features to Show Pages ID, it’s developed by the WordPress community.

Reveal IDs supports multiple languages, in addition to the sortable columns feature that came after WordPress 3.1. If you are fond of coding, Reveal IDs might be right up your alley. Also, you can modify the columns on your WordPress admin area to create a custom function.

However, unless you have ample experience in editing the functions.php file, we strongly recommend you to use WordPress plugins instead.

How to Find the Post ID in WordPress Database

Another way to find a Post ID is through the WordPress database. In that case, what you have to do is:

Find cPanel in Client Area

  • Find phpMyAdmin in the Databases section and click on it:

Find phpMyAdmin in cPanel

  • Once you are inside phpMyAdmin, find the specific database, and click on it. This will show you multiple structures, one of which is wp_posts.
  • After you choose wp_posts, you will be able to see a table with details regarding your WordPress posts. One of the columns shows the post ID:

Find the Post ID in wp_posts

As you could see from the screenshots, here you can also find other IDs (comments, options, etc.) if you need them.

How to Display WordPress Post ID in functions.php

In case your needs are more advanced and you have to query the Post ID and display it on the front-end, WordPress includes the the_ID() function to help you present the ID of a post.

As long as you add the function within the Loop, it will display the numeric ID of the current post.

Here’s a usage example from the WordPress Codex:

Post Number: <?php the_ID(); ?>

Conclusion

Not everyone needs to use WordPress IDs to manage their content. However, as you can see, the process is not at all complicated. Whether you’re using some plugins, themes or code, you will most likely encounter a situation where you need to know the actual ID of a piece of content on your WordPress site. It can help you when customizing, categorizing, or arranging multiple posts.

We hope you find this article useful. Discover more about FastCloud - the top-rated Hosting Solutions for personal and small business websites in four consecutive years by the HostAdvice Community!

Al-Manar Technology Services