How to Find Post ID on your WordPress Site (and why do you need it?)

Easily Find WordPress Post ID | Blog Banner

Last updated - July 8, 2021

You often have come across instances where a plugin, code snippet, or WordPress itself has asked for a Post ID. Although they are not too hard to find, there are several, but simple ways to easily find Post ID on your WordPress site.

In this article, we will explore ways to easily find Post ID on your WordPress site, and also check out why you actually need it.

But before we jump into exploring methods to find Post IDs, we will answer one basic question.

What is WordPress Post ID?

WordPress Post IDs are unique ways for WordPress to identify each element like a post, page, categories, and tags. If you are editing, say a post, WordPress identifies the post with the Post ID. WordPress considers all the above elements as post, but further identifies with post types.

If you are running a WooCommerce store, each product, category, tag, and attribute values can also be uniquely identified with a Post ID. However, the product attributes are identified with their names.

How to find Post IDs on your WordPress site?

Now let’s find out how we can find these WordPress Post IDs.

1. From WordPress Posts Dashboard

This is the quickest way to find a Post ID. All you need to do is go to the WordPress Posts Dashboard by clicking the “Posts” link on the WordPress left sidebar menu. Next, you can hover to any of the posts and find a URL preview on the bottom left corner of the page.

Find WordPress Post IDs | In WordPress Posts Dashboard
In WordPress Posts Dashboard

Based on the sample screenshot shown above, you can notice the URL contains posts=394&. The number “394” is the Post ID for the WordPress post titled “Welcome to the Gutenberg Editor”.

Easy isn’t it?

There is also another way to view this Post ID from the Posts. You can click on the post title link or Edit to open a particular post to edit. You can notice the same Post ID in the URL of the post, as shown in the below screenshot.

Find WordPress Post IDs | In WordPress Edit Post
In WordPress Edit Post

You can access Post IDs for categories, tags, media files, products, product categories, and attribute values in the same way.

2. Using WordPress Plugins

There are some free WordPress plugins available that make your job a lot easier.

You can make use of the Catch IDs plugin that shows the Post IDs in a new column in the WordPress Posts dashboard. The plugin also shows the Page ID, Media ID, Links ID, Category ID, Tag ID, and User ID in the Admin Section Table.

Find WordPress Post IDs | Catch IDs Plugin
Showing IDs with Catch IDs Plugin

Reveal ID plugin is also a good alternative.

3. From Database

If you are a developer or have experience working with PHP, there are some technical methods you can use to access Post IDs.

You can log into your phpmyadmin account, open your site database, and click on wp_posts table. You can find a column titled – “ID” that shows the ID of all the posts on your site. This table also includes IDs for pages, media files, etc., as shown in the screenshot below.

Find WordPress Post IDs | In wp_posts table in Database
In the wp_posts table in Database

What do you need WordPress Post IDs for?

Now that we have seen how to find WordPress Post IDs, let’s discuss why it is needed.

You need to look out for Post IDs mostly when you want to customize your WordPress website. Some themes or plugins require Post IDs to customize at an individual content level, without touching other content.

You can also use them while customizing codes to filter or exclude them using the_ID() function. Using a plugin like Search by ID, you can search for posts using Post IDs in the WordPress Posts dashboard.

Moreover, if you have configured sitemaps for the site, you can use Post IDs to hide certain pages. This is helpful to hide unwanted pages that you do not want to index in the sitemap as well as search engines.

For example, to hide certain pages from the sitemap, add the following code snippet to the functions.php file of your activated website theme.

add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () {
 return array( 311, 322 );
} );

Read How to Edit WordPress Source Code Files?

In addition to this, if you are using WooCommerce, certain plugins require product IDs for operations. For example, the ELEX WooCommerce Bulk Edit Products, Prices & Attributes plugin uses product IDs to exclude products from the bulk editing process, as shown in the screenshot below.

Find WordPress Post IDs | Exclude Product IDs with ELEX Bulk Edit Plugin
Exclude Product IDs with ELEX Bulk Edit Plugin

You can also watch the video tutorial below for better understanding.

Conclusion

Although Post IDs are not essential in everyday front-end tasks like writing blog, eCommerce transaction, etc., WordPress uses it to uniquely identify each piece of content. If you are looking to customize your site, certain themes or plugins do require them.

Especially, if you have an eCommerce store based on WooCommerce, post IDs (or product IDs) are essential in applying customization at the product level.

You can use the straight-forward method of finding Post IDs in WordPress Posts dashboard or simply install a free WordPress plugin.

Hence, it is always better to know where (and how) to find Post IDs on your WordPress Site. It might come handy anytime!

 


You can check out blog articles on WordPress Basics, WordPress Security & Performance, or WooCommerce customizations for learning about different aspects of WordPress and WooCommerce.

Or continue exploring LearnWoo for more amazing articles.

LEAVE A REPLY

Please enter your comment!
Please enter your name here