WordPress Page ID

WordPress Page ID and Where to Find It

WordPress Page ID

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. They are particularly important when working with codes or plugins.

Although IDs are important, WordPress does not make it available on the surface. You have to find it.

That’s the essence of this WordPress resource. You will learn what a page ID is, and how to find your post or page IDs, and other IDs. So stay with me!

Content

What is a WordPress page ID?

WordPress gives a unique number to all your site pages. The unique number assigned to each page is called the Page ID. It allows WordPress to keep track of your entire site’s content.

There are times you may want to apply special styles to just one or a few pages on your WordPress website. And you can achieve that by inputting the ID of that particular page where required.

How to find WordPress page ID

Finding a WordPress page ID is not a difficult task. It can be seen within a page’s URL.

Let’s assume we need to find a page ID for a page titled ‘courses’ on a WordPress site. Simply login to your dashboard and click on ‘pages’. Now, locate the page for which you are trying to get the ID (in this case courses).

Next, let your cursor rest on the word ‘edit’ beneath the page title. You will notice a URL at the base of your browser window. In the URL, check for “post=number ID”. The number after the equals sign is 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 your WordPress Page ID

In the illustration above, 109 is the page ID of the page titled ‘courses’.

Alternatively, you may click the word ‘Edit’ (beneath the page title). When the edit screen opens, check the address at the top of your browser window. You will see “post=number ID” within the URL. That’s the page ID.

Finding Post IDs in WordPress

Finding a WordPress post ID follows the same pattern as finding a page ID. The only difference is that you have to go to ‘Posts’ instead of ‘Pages’ on your dashboard.

Let’s look at an example. Assuming you want to view post ID for a single post titled ‘WordPress Salts’. Go to Posts in your dashboard. And select ‘Edit’ (beneath the post’s title).

How to find post ID - WordPress page ID guide

When the edit screen opens, you would be able to see “post=number ID” in the URL. See the picture below.

How to find post ID

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 or tag id, go to Posts > Categories or Posts>Tags. When it opens, click on Edit for the category or tag for which you are trying to get ID number.

How to find Category ID

The category or tag ID appears in the URL. And here is how it looks.

finding Category ID

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.

How to find media ID

When it opens, highlight the URL in your browser’s address bar.

How to find Media ID

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 WordPress Comments ID

To find a WordPress comment 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.

Finding comments ID

Alternatively, you may just allow the cursor to float over the word ‘Edit’. And the Comments ID will be visible at the bottom of the browser’s window.

finding a comment ID

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 plugins automatically adds an ID column. You can now view your post and page IDs on your WordPress dashboard. Your comments and other IDs will also be displayed when you open those settings pages.How to find WordPress page ID with a plugin

How to display WordPress 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 IDs

So now, you have learnt the different ways of finding your ID for posts and pages, as well as your other content. In this section, we will look at what you can use them for.

To start, you can limit some plugin features to particular pages with their page IDs. Most plugins allow you to add or subtract some pages or posts from the plugin functions by using the ID number of the page or post.

For example, if you’re using Google Analytics plugin, you can prevent tracking of some posts using their ids.

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 particular 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.

Conclusion

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.

More Resources: