find Page ID and post id

How to Find WordPress Page ID?

In WordPress, an identification (ID) number is associated with each of your pages, posts, comments, categories, tags, and media. You may be required to find WordPress page IDs or post IDs while working with codes or configuring plugins.

To understand when you might be required to find a page ID, think of the time when you’re trying to apply some sort of special CSS for a particular page or a common element of one or several pages (your full website). The Page ID of the specific page is used as a class within the CSS. 

The body tag of your WordPress site has many classes. One of these classes is the page ID. Henceforth, the page ID comes in handy as a class while applying specific CSS rules on the body or the other elements presiding within the body (your entire website). 

The page ID class looks like this: page-id-[ID-NUMBER]

IDs are essential, and you should know how to find them. Once you know the method of finding a WordPress page ID, it only takes a few seconds to locate it. 

Interested in knowing how to find a WordPress Page ID? Next, we’ll show you how to find it.

How To Find WordPress Page ID Via The WP Dashboard – Easy Steps 

Step 1: Login to your WP website.

Step 2: Go to the ‘Pages’ section in the admin menu. Then, click on ‘all pages.’ A list of all the pages of your WordPress website will appear.

how to find wordpress page id

Step 3: Hover your cursor over the word ‘Edit,’ which is located beneath the page title you want to know the page ID. Doing so, a link will appear at the bottom of the page, as indicated by the orange arrow in the screenshot below. As you can see, within the URL string, there is a “post=number ID,” wherein the page ID follows the “=” sign.

find wordpress page id

Another way of finding the page ID from the same screen is by clicking the link named ‘Edit’ (shown by the orange arrow above). Doing this will open up the editor, wherein you will see “post=number ID” (that’s the page ID) within the URL on the address bar located on the top of the screen. 

It says post=number instead of page=number because, in the WordPress database, pages get stored as a post type. 

Following the same pattern as finding the Page ID, you can locate the IDs of posts, tags, and categories. For example, to find the post ID, you have to open Dashboard > Posts instead of Dashboard > Pages

Next, having selected the item you want to check the ID for, find the ID from the URL by clicking on ‘Edit’ of the post, category, or tags.

How To Find Page ID In Bulk Using A Plugin? 

A popular WordPress plugin like ‘Reveal IDs’ should be used when you need to find out multiple WordPress page IDs at once or if you’re into finding IDs regularly. This plugin helps you find many IDs at once, including for all posts, pages, categories, and more. 

The Reveal IDs plugin is a breeze to work with. Upon installation and activation, the plugin automatically adds an ID column. Next, all you have to do is visit your WordPress dashboard interface, where you can view all your posts and page IDs. You can also find your comments IDs by opening your comments from the side menu. 

Use PHP To Display WordPress Page ID (or Post ID)

If you need to display a page ID or post ID on the front-end, WordPress includes the the_ID() function. The function allows you to display the numeric page ID.

The only requirement is to add the function within the Loop, and the current ID will get displayed.

Here’s an example from the WordPress Codex:

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

When To Use The Page ID?

We just showed you how easy it is to find the WordPress IDs of pages, posts, tags, and other content. Now, the question arises — When and what may these IDs be used for? 

Here are the main reasons why you may need to use the Page ID:

  • When you install a plugin – To add or exclude specific pages or posts from that plugin’s functionality, you need to use the ID number associated with that particular page or post. 

Example: When using the ‘Google Analytics plugin’ or a ‘Sitemap Plugin,’ you may wish to exclude certain pages or posts from being tracked or seen on the sitemap, respectively. The only way to disallow select pages or posts from being included by the plugin’s function is by using the specific IDs.

  • In situations where you want to alter specific pages without altering others, you can apply CSS rules using the relevant page IDs.

For the above reasons, you must have sufficient knowledge about page IDs and how to locate them. 

Are you wondering if any developments are relieving you of finding an ID? The answer is yes. Certain new plugins have built-in functionality allowing you to choose specific pages or posts using their titles in place of IDs. 

How To Use The Page ID?

Now that you know how to find a page ID, what if you want to use it? The best way to explain how to use the page ID is by using some common examples. 

Example 1: If you want a unique background for a specific page.

You can use the page ID class in the following way: (Copy the Codes)

.page-id-[ID-NUMBER] {

   background: url(“images/your-bg.jpg”);

}

Example 2: If you want the content module hidden on a specific page.

You can use the page ID class in the following way:

.page-id-[ID-NUMBER] .module-class {

   display: none;

}

Final Thoughts

In the article, we’ve outlined what page IDs are and How to find WordPress Post ID using different methods. We also demonstrated the uses and application of IDs. Whether you use code or a plugin, there will be situations when it will be necessary for you to know the IDs of your WordPress site’s specific content. 

Do you have further tips to share from your own experience on this topic? If yes, comment below!

If you liked this article, you’d also enjoy reading the following:

Leave a Comment

Your email address will not be published. Required fields are marked *