To find a WordPress post ID or page ID, go to Posts → All Posts or Pages → All Pages and hover over the title. In the URL preview, the number after post= is the post or page ID. You can also open the post or page in the editor and find the same number in the browser address bar.
WordPress assigns a unique numeric ID to each post, page, and other content item. The dashboard is the quickest way to find one ID, while the page source works without dashboard access. Plugins are useful for checking multiple IDs, while WordPress functions and database access suit developer workflows.
How to find WordPress post and page IDs manually
The quickest way to find a WordPress post or page ID is through its URL in the WordPress dashboard. If you don’t have dashboard access, you can also check the source code of a public post or page.
Find the ID in the WordPress dashboard
You can find a post or page ID by hovering over its title or opening it in the WordPress editor.
If you’re new to managing content in WordPress, the WordPress post editor is where you can create, edit, and organize posts before checking their IDs.
- Go to Posts → All Posts. For a page ID, open Pages → All Pages instead.
- Hover over the post or page title.
- Look at the URL preview at the bottom of your browser. The number after
post=is the post or page ID.
For example, if the URL contains post=123, the ID is 123.
You can also click Edit to open the post or page. The editor URL in your browser’s address bar contains the same post= parameter.
Find the ID in the page source
You can find the ID from a post or page’s HTML source if you don’t have access to its WordPress dashboard.
- Open the published post or page in your browser.
- Right-click the page and select View Page Source.
- Search the source for
postid-if you’re viewing a post orpage-id-if you’re viewing a page. - The number after the class name is the post or page ID. For example,
postid-123indicates post ID 123.
This method works when the WordPress theme outputs the standard body classes. If you can’t find postid- or page-id- in the source, use another method in this guide.
How to find WordPress post and page IDs with a plugin
A WordPress plugin is useful if you regularly need to check IDs for multiple posts, pages, categories, or other content types. Instead of opening each item individually, the plugin displays IDs directly in the WordPress dashboard.
One option is Reveal IDs, which adds an ID column to supported WordPress admin screens.
To use it:
- Install the WordPress plugin and activate it.
- Go to Posts → All Posts or Pages → All Pages.
- Find the ID column next to each post or page.
Reveal IDs also supports IDs for content such as categories, tags, custom post types, and taxonomies, making it more useful when you need to work with IDs regularly.
How to find WordPress post and page IDs with code
Developers can retrieve WordPress post and page IDs using built-in WordPress functions or directly from the WordPress database. Use WordPress functions when working inside a theme or plugin, and check the database when you need to inspect stored content directly.
Retrieve an ID with WordPress functions
The get_the_ID() function returns the ID of the current post or page inside the WordPress Loop:
$post_id = get_the_ID();
To display the ID directly, use:
echo get_the_ID();
If you already know the post URL, url_to_postid() can retrieve its ID:
$post_id = url_to_postid( 'https://example.com/example-post/' );
You can also use get_page_by_path() to retrieve a post or page by its slug:
$post = get_page_by_path( 'example-post', OBJECT, 'post' );
if ( $post ) {
echo $post->ID;
}Find an ID in the WordPress database
Post and page IDs are stored in the ID column of the WordPress posts table. This method is useful when you already have database access and need to inspect IDs directly.
- Open phpMyAdmin from your hosting control panel.
- Select your site’s WordPress database.
- Open the
wp_poststable. Your table prefix may differ fromwp_. - Find the relevant post or page and check its
IDcolumn.
The wp_posts table also contains fields such as the post title, slug, status, and content type, which can help you identify the correct entry.
What can you do with a WordPress post or page ID?
Once you know a WordPress post or page ID, you can use it to target specific content in custom code, shortcodes, queries, plugins, or theme settings. For example, you might use an ID to include or exclude a particular post from a custom list or apply functionality only to one page.
If you need the ID for custom PHP, follow safe methods for adding PHP code to WordPress rather than modifying WordPress core files. Back up your website before changing theme or plugin code.
All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.

