In WordPress, everything has an identification (ID) number. This includes your pages, posts, media, comments, categories and tags. You may have had instances where you needed to find a WordPress page or post ID – maybe while working with codes or while configuring a plugin.
So, here is the big question: how do you find a WordPress ID? That’s the essence of this article. Although IDs are important, WordPress does not make them available on the surface. You have to find them.
In this guide, you will learn what an ID is, how to find your post or page IDs, and other IDs too. Stay with me!
- What is a WP page ID
- How to find page ID
- Finding Post IDs in WordPress
- How to Find Category,Media and Tag IDs
- Viewing WordPress Post ID with WordPress plugins
- How to display ID With PHP
- What you can do with page IDs
What is a WordPress page ID?
WordPress gives a unique number to all your site’s pages. The unique number assigned to each page is called the Page ID. It allows WordPress to keep track of each and every site content.
They are useful when you need to add widgets on specific pages. You may also need IDs to apply special styles to just one or a few pages on your WordPress website. These IDs grant you flexibility on your website.
How to find WordPress page ID
Finding a WordPress page ID isn’t difficult. It is usually located within the page’s URL.
Let’s see an example: I have a page on my WordPress site with the name “courses”. To find its ID, here are the things to do.
Login to the WP dashboard and click on ‘Pages’. Now, locate the page (“courses” or the page for which you are seeking its ID).
Next, let your cursor rest on the word ‘edit’ beneath the page title. Check the base of your browser window, you’ll see the Page URL. Within the URL string, check for “post=number ID”. The number after the equals sign is the page ID.
In the illustration above, 109 is the page ID of the page titled ‘courses’.
Alternatively, you may click the link ‘Edit’ (beneath the page title). When the editor opens, look at the address at the top of your browser window. You will see “post=number ID” within the URL. That’s the page ID.
Side note: In case you’re wondering why it says post=number when it is a page number, WordPress pages are stored as a post type in the database.
Finding Post identification number in WordPress
Finding a WordPress post ID follows the same pattern as finding a page ID. The only difference is this – You open Dashboard >> Posts instead of Dashboard >> Pages.
Let’s see another example. I have a post titled ‘WordPress Salts’. To find its ID, go to Posts in your dashboard. Select ‘Edit’ (beneath the post’s title).
When the editor opens, you would be able to see “post=number ID” in the URL. See the picture below.
The post ID for our blog post titled ‘WordPress salts’ is 263.
How to Find Media, Category, and Tag IDs in WordPress
Every piece of content on your site is referenced and stored in your WordPress database with a unique number. Thus, everything (not just your posts and pages) have unique IDs. In this section, you will learn how to find the IDs of your Media Content, tags and categories.
The process is similar to what we discussed above.
For category id, go to Posts > Categories. To get your tag id, go to Posts >Tags. When it opens, click on Edit for the category or tag for which you are trying to get ID number.
The category or tag ID appears in the URL. And here is how it looks.
Instead of “post=number ID”, it is “tag_ID=number ID” for categories and tags. The category ID in the illustration above is “1”.
The same approach applies to finding a media ID. Click on media on your dashboard menu. Next, select the particular picture or video.
When it opens, highlight the URL in your browser’s address bar.
There you go. “item=number ID” becomes visible in the URl. The media ID in the example above is 137.
You will need this knowledge when creating a default gallery shortcode in WordPress.
How to Find Comments identification number
Finding a WordPress comment is similar to the procedure for finding a page ID. Head over to Comments on your WordPress dashboard. Next, locate the comment you want to work with and click Edit. The comment opens up in a WordPress edit screen. Highlight the URL in the address bar and your comment ID then becomes visible.
Alternatively, you may just let your cursor float over the word ‘Edit’. And the Comments ID will be visible at the bottom of the browser’s window.
Viewing WordPress Page IDs with WordPress Plugins
If you have to view many IDs at once, you may use a plugin to ease the process. Reveal IDs is one of the many plugins used for viewing IDs easily. If you need help with plugin installation, read our article on how to install plugins.
The plugin automatically adds an ID column upon installation. You can then view your post and page IDs on your WordPress dashboard. Your comments IDs will also be displayed when you open your comments.
How to display Page or Post ID With PHP
If you have a need for it, you can also display page id or post id using PHP on your frontend. WordPress has the_ID() function that lets you put a Page ID on display.
All that is required of you is to include the function, and the ID will be displayed.
See this example from the WordPress Codex:
<p>Post Number: <?php the_ID(); ?></p>
What You Can Do With Page identification number
So now, you have learnt how to find IDs for your posts and pages, as well as other content. But, what do you need them for?
To start with, when you install a plugin, you can add or subtract some pages or posts from the plugin functions by using the ID number of the page or post.
For instance, Google Analytics plugin are useful in tracking the performance of posts. If there is a post you don’t want to track, exclude it using the post ID.
Also, if you use a Sitemap plugin, you may choose to disallow some parts of your WordPress website from showing on the map. And you can achieve this using their IDs.
Further, there will be times when you need to change a specific page without affecting others. You can do this by applying css rules using the page ID.
Many plugins use this approach, so your knowledge of page Ids and where to find them is valuable. However, some other plugins have adopted a more friendly approach. These new plugins lets you choose specific pages or posts using their titles instead of IDs. This development relieves you of the task of finding an ID.
Have you been experiencing ID problems while configuring your WordPress theme and plugin. If yes, I hope this article has helped you.
Remember, you only need to check the number in your browser’s address bar. And if you want an easier method, you can install and activate Plugins like Reveals ID.
Do you have further questions on finding your page ID? You may ask them in the comments section below.
Also, you may check out our blog for other WordPress tutorials. This knowledge base will help you make your WordPress website fast, secure, and successful. It’ll also guide you on making the best choices in WordPress hosting, WordPress theme selection, the right plugins for your site, and more.
- How to Create and Manage Custom Navigation Menus in WordPress
- WooCommerce Shortcodes
- How to Use the WordPress Image Editor