WordPress assigns a unique IDentification number by default known as ID to page, post, media, categories, tags, and comments. Using this number, you can configure a plugin setting for that particular page ID or post ID, So the question arises how to find WordPress page ID or post ID?
Although the page ID or post ID is important to know for many reasons, like applying specific CSS styling or applying any other plugin function, WordPress does not make it available, and you have to find them. But don’t worry; finding your WordPress post ID or page ID is not that difficult as it seems.
In this guide, you will learn what WordPress ID is? What are its uses, and how to find your WordPress page ID or post ID?
What is a WordPress Page ID or Post ID?
WordPress Websites is made by combining different pieces of content and managing those different pieces of content; the ID is used. These IDs are unique to every content like page ID, post ID, comments, user ID, media files, categories, and tags.
The ID number comes in handy when you want to organize the content in your wordpress database, and it will enable you to find and target particular content to apply your changes easily.
The page ID or post ID is useful when you work on your WordPress site to implement some custom coding or work on plugins and themes and only target a specific post or page for the changes to take effect.
By the page ID and post ID, you can also exclude particular pages and posts, or you might want to display a wIDget of some pages and not on others, so with the help of Page ID and post, you can fulfill your desired results need.
So the WordPress ID will give you much control over your website and customize it according to your particular needs.
As you are well aware of how important the page ID and post ID are in wordpress, let’s now get back to how to find page ID or post ID in wordpress?
Read also: How to Find WordPress Category Id?
How to Find WordPress Page ID
Finding the WordPress page ID is such a quick and straightforward process. Follow the steps below to find your page ID in wordpress.
- Open your WordPress Dashboard
- Go to Pages > All Pages
- Select the page you need the ID for and open it
- Once the page is open, look at the URL of the page in the browser address bar, and there you will find your page ID display within the URL of the page
How to Find WordPress Post ID
Finding the WordPress post ID is such a quick and straightforward process as finding your page ID, but you have to go to posts instead of pages. Follow the steps below to find your post ID in wordpress.
- Open your WordPress Dashboard
- Go to Posts > All Posts
- Select the post you need the ID for and open it
- Once the post is open, look at the URL of the post in the browser address bar, and there you will find your post ID display within the URL of the post
Find Page ID and Post ID with Reveal IDs Plugin
If you are a developer and always have to work on page ID and post ID. Hence, there is also a free plugin called Reveal IDs which will help you in finding the page ID and post ID and will speed up your development process, and you will have to only go to the pages and post, and it will show the page ID and post ID in a separate column in next to every page and post.
Reveal IDs is a well-known plugin, and many users love it as it has almost 70 thousand plus downloads with a max of five-star reviews because it is easy to use and can do the job without extra effort.
It finds the wordpress page ID or post ID; it can also be used to find other pieces of content ID like the tag, category, user, comment, and different types of content in WordPress.
So below are steps on how to install and use the reveal IDs plugin for finding your post ID and page ID in WordPress.
Step 1: Install Reveal IDs Plugin
- For Installing the Reveal IDs plugin, open your WordPress dashboard and Go to Plugins>Add New
- Search Reveal IDs in the plugin search
- Once found Install and Activate the Plugin
The Reveal IDs will now be installed.
Step 2: Find Page and Post ID with Reveal IDs Plugin in WordPress
Once Reveal IDs is installed, it does not need any configuration, and you can find the page ID and post ID or any other ID in your WordPress immediately.
So to View, the page ID, Go to Pages > All Pages from the wordpress Right Menu.
Here you will find all your pages with it page ID listed below the column ID
If you want to find the post ID with Reveal IDs you will Go to Posts > All Posts from the WordPress Right Menu
Here you will find all your posts with it post ID listed below the column ID
How To Find Page and Post ID Via Inspect Element
If you are comfortable with code you can also find the page ID using the Browser inspect element.
- Open the page or post on your preferred browser (Safari, Chrome , Firefox, Microsoft Edge)
- Right Click anywhere on the page and Select Inspect from the menu
- Now search insIDe the markup the ID will be at the beginning
- Many Classes will be there search for the “page=ID” class, and once you find it, you will have your page ID
How to Find Page or Post ID with PHP
If you are comfortable with the coding on wordpress, you can also use PHP code to display the ID of post and page on your wordpress Frontend by using the PHP code.
WordPress Has the_ID() function that is used to put the page ID on display. All you have to do is to include the function, and the ID will be displayed.
Below is the example of the Code:
<p>Post Number: <?php the_ID(); ?></p>
Find your WordPress Tag ID and Category ID
Category ID and tag ID are also essential to find as these are frequently used, and configuring any theme and plugin setting, you will need them.
So finding the category and tag follow the same steps as finding a post ID or page, but there is a slight change in where to look for it.
Below are steps for finding your categories and tags ID in wordpress.
- Open your WordPress Dashboard
- Go to Post and Select Categories or Tags form there
- Now open a Category or Tag For which you need the ID for
- Once Open check out the URL, and you will find the tags ID or category ID in the browser address bar
Find the Comment ID Number
WordPress Comments also have an ID number. To find the comment ID number go to your wordpress dashboard. Now Go to the comment section in the side menu of WordPress and edit the comment you want the ID for.
The URL of the comment in the Browser will have the comment ID number. Also, you can find it by only hover the cursor on word edit in the comment section, and it will display the comment information on the bottom from where you can find the comment ID.
Find Image ID Number
As every WordPress content has its unique ID same is the case with WordPress media and other files. They also have an ID, so in case you need it for some specific functionality.
Finding the ID number of media files in wordpress is similar to the other methods we discuss. For this, you have first to open your WordPress dashboard.
Go to the Media > Library. Open the image you want the ID for, and you can find it by looking at the URL of the image in the browser address bar there, you will find the image ID number.
What is the Use of Page and Post ID in WordPress
So as you learn how to find the page ID and post ID, why do you need them for?. The page ID and post ID help you when you install a plugin and want to restrict or add certain pages in the plugin function. You can do it by using the ID number of that page or post.
For example, if you are using a Google Analytics plugin on your website which is used for tracking the performance of posts and pages and if you want to exclude a certain page that is of no use to you, So for achieving this, you will need a post or page ID of that particular page then you can restrict it from google analytics.
Also, if you are using a Sitemap plugin for your website and there are some pages, you don’t want to include in your sitemap like the welcome page etc. So you can remove it from the sitemap plugin using the page ID of that page.
Also, the page ID and post ID come in handy when you want to apply CSS styling on some specific pages without affecting others, so you can apply the CSS rules using the post ID or page ID.
Plugins usually use the ID for IDentification of pages and post to apply their functionality, so knowing how to find the page ID is a skill you will need at some time if you are someone who usually deals with websites.
Also, Many Plugins adopted user-friendly approaches where you can only use the title of a page instead of their ID to apply the changes, which helps the user not look for the ID and do the task with ease.
FAQ (How to Find WordPress Page Id or Post Id)
How to change page id in WordPress?
If you want to change the page id of your WordPress, you have to update the database value, and it’s not an easy task for novice users to either go with changing the permalink from Settings > Permalinks.
WordPress get current page ID in functions PHP
The Code for getting the current page id in Function PHP is:
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$post = get_post();
return ! empty( $post ) ? $post->ID : false;
}
Conclusion
Finding your WordPress page id and post id is a straightforward process and will barely take a minute of you either from the permalink of the page or with the help of the reveals ids plugin.
Also, the methods discussed in this article are applied not only to page id or post id but also to any other content, whether its user id, comment, media, etc.
Hopefully, after reading this article, you will learn something new about page id and post id; so still, if you have any questions, feel free to ask in the comments.