The easiest way to find Post ID on Wordpress is to know it





There will be times when using WordPress you may need to obtain an ID ID, for the plugin or perhaps you are a developer and need to query it. See instructions below on how to easily find post IDs from within your WordPress dashboard and also by code.

As with your identity card number, every page, post, and custom post type in WordPress has their own unique digital post ID assigned to them in the database to identify them together. . Behind the scenes, post ID is used by queries for all types.

How to find the post ID

When working with different WordPress themes and plugins, there will be times when they may require a Post ID. Typically, they are used to filter posts and exclude them. For example, the plugin Display Widgets Free lets you 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.

Commas are separated by the post ID

Commas are separated by the post ID

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

WordPress receives the post ID

Another way to find it is to edit your post and the post ID will appear in the address bar of your browser. This also applies to pages, custom post types, etc.

Post ID in the address bar

Display the post ID in the WordPress Dashboard

When WordPress 2.5 was released, the post ID was no longer displayed in the dashboard. However, if you work with a lot of post IDs, there are some easy ways to re-enable that function. The first way is to just use a free plugin named Show ID

Wordpress plugin displays id

Show WordPress plugin ID

This plugin is lightweight, accurate to only 3 KB and does not make any terminal calls. When writing this article, it now has more than 10,000 active installs with a rating of 5 out of 5 stars. You can download it from WordPress repository or by searching it in your WordPress dashboard in the Add Add New add-on. There is nothing to configure, just install, activate and post ID will show up in your control panel. It also supports page ID, category ID, tag ID, category ID, etc.The following is an example of what you will see later.

Display post id in wordpress dashboard

Display the 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 ID in your WordPress dashboard with code .

Get post ID function

If you are a theme or plugin developer and need post ID queries, you can use the following functions. Use the following code in a loop to Show ID number of the current post.

the_ID (); ?>

If you are working outside the loop, say in the footer. You cannot use the above function to obtain post IDs. Instead, you must use the following:

$ post-> ID

Example:

function function_name () {

global $ post;

$ thePostID = $ post-> ID;

}

About My name is Nguyen Manh Cuong. I was born in a poor village in Ba Vi district, HA NOI province - windy and sunny land. Currently. https://www.nguyendiep.com/. Mr Cuong.
Newer Posts Newer Posts Older Posts Older Posts

Comments

Post a Comment