Setup & site building · Guide
How to Find a Post or Page ID in WordPress

Short answer
Open the post or page in the editor and read the number after post= in the browser address bar, such as post.php?post=123. You can also hover over the title on the Posts or Pages list to see the same number, add an ID column with the Reveal IDs plugin, or read the page-id number from the page source.
Key takeaways
- A post or page ID is a unique number that never changes when you edit the title or slug.
- The fastest check is the editor URL: read the number after post= in post.php?post=123.
- WordPress removed ID columns from admin screens in version 2.5; the Reveal IDs plugin puts them back.
- Reveal IDs has more than 40,000 active installations and version 1.6.3 was updated on 15 August 2026.
- get_the_ID() works inside the Loop, while get_queried_object_id() gives the page itself outside it.
- wp post list prints IDs and titles in bulk, and the body class carries page-id-2 on the front end.
What is a WordPress post or page ID?
A post or page ID is the unique number WordPress gives each piece of content in its database, and it never changes when you edit the title or slug.
Every post, page, media file, category, tag, comment and user has its own ID. WordPress uses that number behind the scenes to tell two posts apart, even if they share a title. Shortcodes, widgets, menus and theme code often ask for an ID instead of a title for that reason.
The ID is a plain integer, such as 123. It is set when the item is first saved, and it stays with that item for its whole life.
You will need an ID when a plugin asks for a page to use as a landing page, when a shortcode needs a post to show, or when theme code must load one exact page. The methods below find it in seconds, with no code needed for the first three.
| Method | Needs | Best for |
|---|---|---|
| Editor URL | Admin access | One quick lookup |
| Hover on the list screen | Admin access | One quick lookup without opening the editor |
| Reveal IDs plugin | Admin access | Looking up IDs often |
| Page source | None | No admin access |
| Theme code | Code access | Templates and plugins |
| WP-CLI | Server access | Bulk lookups |
How do you find a page ID in the editor URL?
Open the post or page in the editor and read the number after post= in the browser address bar.
Follow these steps:
- Go to “Pages → All Pages” or “Posts → All Posts” in the dashboard.
- Click the title of the page or post you need.
- Look at the address bar. It shows a URL such as
https://yoursite.com/wp-admin/post.php?post=123&action=edit. - The number after
post=is the ID. In that example, the page ID is 123.
The WordPress.org Find Page ID support topic describes this same URL pattern. The parameter is called post even when you edit a page, so do not look for a page= value.
The editor opens in the block editor by default. The guide to how to use the WordPress block editor covers the editor screens if the layout is new to you.
This method works for posts, pages, media items and custom post types alike, since they all open at the same post.php?post= address. It needs no plugin and no code, so use it first.
How do you find an ID without opening the editor?
Hover over the title on the Posts or Pages list screen and read the post= number in the link preview at the bottom of the browser.
Follow these steps:
- Go to “Pages → All Pages” or “Posts → All Posts”.
- Move the mouse over the title of the item you need.
- Look at the bottom-left corner of the browser, where the link address appears.
- Read the number after
post=in that address.
This hover trick suits a quick check of one or two IDs. You never leave the list screen, so it is faster than opening each editor in turn. The WordPress.org Find Page ID support topic notes this hover method as well, and points out that the status bar shows the same post= value.
If your browser hides the link preview, click the title to open the editor and read the ID from the address bar instead. Both routes show the same number, so use whichever your browser makes easy.
How do you show an ID column on list screens?
Install the free Reveal IDs plugin, which adds a sortable ID column to the Posts, Pages, Media, Categories, Tags, Users and Comments screens.
Follow these steps:
- Go to “Plugins → Add New” in the dashboard.
- Search for “Reveal IDs”.
- Click “Install Now”, then “Activate”.
- Open “Pages → All Pages” and look for the new ID column.
The Reveal IDs plugin page states that the plugin reveals the entry IDs on admin pages, as WordPress showed them before version 2.5. WordPress removed those ID columns in version 2.5, and this plugin puts them back.
The plugin has more than 40,000 active installations and a 5 out of 5 star rating from 61 reviews, as the Reveal IDs plugin page shows. The current release is version 1.6.3, updated 15 August 2026, with WordPress 7.1 support.
The columns are sortable, so you can order a list by ID to find the newest or oldest items fast. The plugin page notes that the sortable columns work on WordPress 3.1 or higher, so they run on any site kept up to date.
How do you find an ID from the front end of the site?
Open the page in the browser, view the page source, and search for page-id- to find the number WordPress put in the body class.
WordPress adds a class such as page-id-2 to the <body> tag of each page. The body_class() reference shows an example body tag reading class="page page-id-2 page-parent page-template-default logged-in", where 2 is the page ID.
Follow these steps:
- Open the page on the front end of the site.
- Right-click the page and choose “View Page Source”, or press Ctrl+U on Windows or Cmd+Option+U on Mac.
- Press Ctrl+F or Cmd+F and search for
page-id-. - The number after
page-id-is the page ID.
This method works when you have no admin access to the site, such as when a client asks for the ID of a page on their own site. It also works for posts, which carry a postid- class in the same body tag.
To inspect the live page instead, open Chrome DevTools: right-click an element and choose “Inspect” to open the Elements panel, as the Chrome DevTools DOM guide explains. MDN's browser developer tools guide adds the shortcuts Ctrl+Shift+I or F12 on Windows and Linux, or Cmd+Option+I on Mac.
How do you get the ID in theme code with get_the_ID()?
Call get_the_ID() inside the WordPress Loop to get the ID of the post or page now being shown.
The get_the_ID() reference states that the function retrieves the ID of the current item in the WordPress Loop. It returns an integer, or false if no post is set. The function has existed since WordPress 2.1.0, so it runs on any modern site.
A simple use looks like this:
<?php
$post_id = get_the_ID();
if ( $post_id ) {
echo 'The current post ID is: ' . $post_id;
}
?>
Use this function inside single.php, page.php or any template part that runs in the Loop.
A custom page template often needs the ID to load page-specific content. The guide to how to create a custom page template in WordPress shows how such templates are built and assigned.
Do not use get_the_ID() outside the Loop and expect the right answer. On a blog listing page it returns the ID of the first post in the list, not the ID of the page itself. The next section covers that case.
How do you get the ID outside the Loop?
Call get_queried_object_id() to get the ID of the page, post or term the main query is showing, even outside the Loop.
The get_queried_object_id() reference states that the function retrieves the ID of the currently queried object. It has existed since WordPress 3.1.0. Use it in a header, sidebar, plugin hook or template part where the Loop may point at the wrong item.
The difference shows up on the blog page. The notes on the get_the_ID() reference warn that on the blog home page it returns the first listed post ID instead of the blog page ID.
For example, if the blog page itself has ID 8 and the newest post in the list has ID 4517, get_the_ID() inside the Loop returns 4517, while get_queried_object_id() returns 8.
A short example:
<?php
$page_id = get_queried_object_id();
echo 'This page ID is: ' . $page_id;
?>
On a category archive, the same function returns the term ID, not a post ID, since the queried object there is the category. Pass that number to term functions, not post functions, or the result will be wrong.
How do you find IDs in bulk with WP-CLI?
Run wp post list with the --fields option to print IDs and titles for many posts or pages at once.
WP-CLI is the command-line tool for WordPress. The WP-CLI site states that anything you can do in the admin can be done from the terminal, including listing posts. It has shipped since 2011.
List pages with their IDs like this:
wp post list --post_type=page --fields=ID,post_title,post_status
The wp post list documentation states that the default columns are ID, post title, slug, date and status, and you can narrow the output with --fields.
To get IDs only, run:
wp post list --post_type=page,post --format=ids
The same documentation shows that command printing a plain list such as 15 25 34 37 198. That output pastes straight into a script or a search.
You can also look up one post by its ID with --post__in=1,3, or filter pages by a page ID with --page_id, as the wp post list documentation explains. The --page_id filter needs --post_type=page to match anything.
What mistakes should you avoid?
Do not confuse the ID with the slug, do not use get_the_ID() on a blog listing page, and do not hard-code an ID that a fresh import will change.
Other mistakes to avoid:
- Reading the number in the front-end URL, which is the slug, not the ID.
- Using a category ID where a post ID is expected, since archive pages return term IDs.
- Keeping the Reveal IDs plugin active forever when you only needed one lookup.
- Showing a page in one widget by ID and forgetting the ID changes if the page is rebuilt.
Targeting a page by ID in CSS needs a check of the body class first. The guide to how to add custom CSS in WordPress shows where that CSS goes.
The guide to what a widget is covers where widgets display and how they pick their content.
Write the ID down next to the page name when you look it up, and note the date. A short list of IDs for your key pages saves a repeat lookup the next time a plugin asks for one.
Frequently asked questions
Does a post or page ID change when I edit its slug?
No. The ID is a number WordPress assigns when the item is first saved, and it stays the same when you edit the title or slug. The slug is the text in the front-end URL, while the ID is the number in the admin URL after post=.
Does the ID stay the same if I move a page to another site?
No. The ID is unique to one item on one site, and it is not part of the content that moves. After an import, the same page gets a new ID on the destination site, so update any shortcode, widget or code that used the old number.
Why does get_the_ID() give the wrong ID on my blog page?
Use get_queried_object_id() instead. On a blog listing page, get_the_ID() inside the Loop returns the first post in the list, not the page itself. The queried-object function returns the ID of the page the main query is showing.
Can I find a page ID without logging in to the dashboard?
Yes. Open the page on the front end, view the page source, and search for page-id- to find the number WordPress put in the body class. This works without admin access, which helps when a client asks for an ID on their own site.
Does WordPress show IDs on the Posts and Pages list screens?
No, unless you use a plugin that adds an ID column, such as Reveal IDs. WordPress removed the ID columns from admin list screens in version 2.5. The URL method and the hover trick work without any plugin.
Do categories and users have IDs as well?
Categories, tags and users have IDs too, and they appear in the same places: the admin URL, the Reveal IDs columns and WP-CLI output. On an archive page, get_queried_object_id() returns the term ID, so pass it to term functions rather than post functions.
Sources
- get_the_ID() WordPress Developer Resources
- get_queried_object_id() WordPress Developer Resources
- Reveal IDs WordPress.org
- wp post list WordPress Developer Resources
- body_class() WordPress Developer Resources
- Get started with viewing and changing the DOM Chrome for Developers
- Find Page ID WordPress.org
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


