How to find the page ID in WordPress in a few steps

How to find the page ID in WordPress in a few steps

WordPress users often need to find the WordPress page ID, which is especially important when working with codes or plugins. This article will discuss how to find the page ID in WordPress.

Everything you see on your WordPress page has an identification number, including posts, pages, media, comments, and even tags. With so many posts and comments or media, it’s sometimes hard to find the specific one you need for your codes or plugins.

IDs won’t be visible as the default, so you need to search for them and this article created by our team at wpDataTables will show you how to find page ID in WordPress.

About WordPress Page ID

Finding the page ID in WordPress can be a little difficult in the normally easy-to-use WordPress platform.

What does WordPress page ID tell us?

Knowing how to find page ID in WordPress is especially useful if you’re searching for specific posts or materials on your page, and when you’re trying to exclude pages from the Pages widget.

WordPress as a default uses the page’s ID to find the pieces of content, then using that ID, places the content on the widget, so it’s important to know the ID. It’s also useful to know the ID if you want to target specific content or pages.

ID numbers usually consist of 1-4 digits, which are used to signify and define pages or content.

For example, you want to define a specific style on your WordPress page, but only for some individual posts or pages, so you insert the ID of the page or post in question.

If you want to make a blog post disappear from the website, you have to find the ID of the post in order to do so.

How to Find Page ID in WordPress

Although the ID will be hidden, it’s not hard to find it within the URL of the page and then make it visible.

  • For example, let’s take a look at the ID for a page called “courses”. To find it, log into your WP dashboard, and go to Pages. Next locate the page you want the ID for.
  • Next, move your cursor to the Edit button and hover over it. Then, look at the site’s URL. Somewhere in the middle, you should see something like this:

?Post = there are 1-4 numbers after it. This is the page’s ID.

  • WordPress names pages as posts, so the pages will have the marker post before the number.
  • Another way of finding page ID in WordPress is to click on Edit. Then, when the subpage opens, check the URL at the top of the browser. You’ll see the number ID after the Post section.

How to Find Post IDs

The technique for finding post IDs is similar to finding a page ID, simply

go under Posts and not under Pages.

For example, if you would like to find the ID for the post called “WordPress Salts”, find it under the Posts page. Then select Edit.

When the page for editing opens, you should be able to see the “post=number ID”. The number after the post is also the ID number of this post. In this example, the post ID number is 263.

How to Find Media, Category, and Tag IDs in WordPress

Almost everything has an ID number in WordPress, including media, categories, and tags. This is how to find IDs for media, categories, and tags.

  • Edit the item you want to find ID for, and look for the number in the URL.
  • For example, this is how the ID would look like for categories:
  • Now it’s different; instead of post=ID, it’s category & tag=ID number.

  • With the same method, you can also locate the ID for media. First, select the video or image you want to view the ID of. Then, highlight the URL, and find the ID under the “item=ID number” part.

  • Media ID is useful to create galleries where you have to enter the ID number for creating shortcodes however most of the time you’ll work with post and page ID numbers.

Finding Comment ID numbers

In WordPress even comments have ID. To find it, go to your dashboard, then to the Comments section, find the comment and click Edit. In the edit screen, highlight the URL and find the ID number of the comment from there.

Another way to easily find a comment ID is to go to the comment, float over the word Edit, and find the ID at the bottom of the page.

Finding ID with Browser’s Inspection Tool

You only need to be slightly more comfortable with code for this method, it’s not very complex.

  • Go to your preferred browser (Chrome, Firefox, Safari)
  • Right click anywhere on the page you want to find the ID for, and click on Inspect Element.
  • Then, search inside the markup. The ID should be at the beginning.
  • There are many classes to view; search for the “page=id” class. There, you can locate the page’s ID.

Finding WordPress Page or Post ID via PHP

You can also display the ID on the front end of the page. You’ll find the _ID() function useful for finding the ID of the post or page.

Simply include the function, and you should be able to see the ID.

This is just an example:

<p>Post Number: <?phpthe_ID(); ?></p>

Why Are IDs Useful

What are IDs useful for?

There are many things that we can use the ID for.

Creating Special Background for Specific Pages

The ID is useful if you only want a background for just one page, you can use the ID this way:

.page-id-[ID-NUMBER] {

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

}

You can copy the text, or add a different header color background just for two pages. In this case, you’ll need this code:

.page-id-[ID-NUMBER] .site-header-class,

.page-id-[ID-NUMBER-2] .site-header-class {

   background: #000000;

}

If you have a content module that you want to be hidden on a specific page. In this case:

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

   display: none;

}

Use Plugins for Specific Posts or Pages

With many plugins, you must include the ID of the page or post in order to affect specific posts or pages.

In this example, the Advanced Ads plugin allows you to target specific pages only:

You can also use shortcode parameters with some plugins.

There are plenty of plugins that still use this approach, so you’ll need to know the specific page ID or post ID.

If you know the ID, you can prevent Google Analytics from tracking certain posts or pages.

If you know IDs, you can disallow certain parts of the page using the Sitemap plugin.

Many plugins are becoming increasingly user-friendly so you don’t need to enter the ID number, but you can use the content you’d like to change.

Changing Particular Pages

In some cases, you’ll want to change a specific page without affecting others. You can apply CSS rules with the page ID easily.

Ending thoughts on how to find the page ID in WordPress

In WordPress, everything is under IDs. They are not immediately visible in WordPress, but it’s not complicated to find them. Follow the steps outlined above and you should be able to find whatever you need.

If you enjoyed reading this article on how to find the page ID in WordPress, you should check out this one about how to change fonts in WordPress.

We also wrote about a few related subjects like how to download the WordPress media library, how to embed a WordPress iframe, how to eliminate render-blocking JavaScript and CSS in above-the-fold content, how to stop a DDoS attack and how to hide page title in WordPress.

Up Next:

WooCommerce not sending emails? How to fix it.

WooCommerce not sending emails? How to fix it.