by admin
December 23, 2021

How to get the WordPress page ID and post ID easily

There are a lot of situations when you might need to know what a specific page or post’s ID is in WordPress. In this post, ArrowTheme will show you how to find the ID for the various pieces of content on your WordPress website, as well as some effective ways in which you can use those IDs on your site.

What Is a WordPress Page ID and Post ID?

You may not know it, but WordPress provide every piece of content on your website its own unique ID number.

Without having too much into database structure, let’s just say that this allows WordPress to keep track of all pieces of content on your website

When WordPress require to serve up content, it uses the ID number to search each specific piece of content. Which means that if you need to query/target specific content, it can be helpful to know how to find WordPress page and post IDs.

If you want to see this for yourself, you can take a dive into your WordPress site’s database to see it in action:

Wordpress page id

Get the WordPress page ID and post ID without a Plugin

Finding your WordPress page ID or post ID is a an easy process. To find a page ID, move your WordPress dashboard and click on Pages > All Pages.

Wordpress page id

Then, choose the page that you need to find the ID for. Here, I have selected my Contact page:

Wordpress page id

Once the web page has opened, you need to look at the URL in your web browser’s address bar. Here, you will find out the page ID number showcased within the page URL.

Related:  How to update php version in your Wordpress website and why you should implement it
Wordpress page id

To find out a WordPress post ID, follow the same procedure. Log into your WordPress dashboard, then choose Posts > All Posts.

Wordpress page id

After that, you click on a specific post that you need the ID for. You are in the post Editor, view the post’s URL in your web browser’s address bar to find out the ID number.

Wordpress page id

Getting Your WordPress Tag ID and Category ID without a Plugin

Getting a WordPress tag ID or category ID can also be done in the same way as above. Within your WordPress dashboard, choose Post, then Categories or Tags. Here, we have chosen Tags:

Wordpress page id

After that, you click on the Tag that you need the ID for. Once in the specific tag editing page, check the URL in your web browser’s address bar and you will see the tags’ ID.

Wordpress page id

Use a Plugin to Get Post IDs in WordPress

If you need to work with post and page IDs on a regular basis, you might need a bit more user-friendly approach to get post IDs and page IDs in WordPress.

You can have a look at the free Show IDs by 99 Robots plugin adds an ID column to all of the aforementioned pieces of content.

All thing you need to do is install and activate the plugin. After that, you’ll find out a new ID column in your WordPress dashboard interface:

Wordpress page id

In the default, you’ll see the ID column in every single “Edit” interface. That is, it will stand for:

  • Posts
  • Pages
  • Custom post types
  • Categories and tags
  • Media library items

But if you need to hide the column for types of content, you can utilize the built-in Screen Options to hide it.

Related:  How to fix :fatal error: allowed memory size of 41943040 bytes exhausted in Wordpress

First, move to open the Screen Options:

Wordpress page id

Next step, you uncheck the box for ID:

Wordpress page id

Display WordPress Page ID or Post ID With PHP

Finally, if you want to show a piece of content’s ID on the front-end, WordPress includes the the_ID() feature to help you get the numeric ID of a post.

As long as you include the function within the Loop, it will print the current ID.

Here’s a usage example from the WordPress Codex:

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

Final Thoughts

Knowing how to find a post ID or page ID in WordPress can really come in helpful when you need to reference specific content on your site.

Besides, whether you are looking to build robust WordPress websites, redesign existing website, or seeking a professional maintenance & Support service, our WordPress Development Packages provide you with a team of experts who are ready to help you achieve your business goals.

Especially, you can get up to 30% off for all of your WordPress servicesContact Us to Get a Free Consultation

Related Posts