How to Find WordPress Post IDs and Page IDs

March 7, 2024 / WordPress

This article will help us understand how to find WordPress post IDs and page IDs. These can be useful for various purposes, such as customising themes, creating custom queries, or troubleshooting.

Here is how to find them-

From WordPress Dashboard –

  1. Log in to WordPress.
  2. Navigate to “Posts” or “Pages” depending on whether you want to find the ID of a post or page.
    WordPress Dashboard
  3. Move your mouse cursor over the title of the post or page. Look at the bottom left corner of your internet browser. You will see a small window showing the website address (URL). Find the number after “post=” for posts or “page=” for pages in that website address. That number is the post or page ID.
    website url at bottom

Using WordPress Editor –

  1. Navigate to the post or page you want to find the ID for.
    Posts
  2. Open the post or page in the WordPress editor.
  3. Look at the URL in your browser’s address bar. The post or page ID is the number that comes after post= for posts or page= for pages in the URL.
    page ID number

Using phpMyAdmin (Advanced Method) –

  1. Log in to your hosting control panel and access phpMyAdmin.
    Databases
  2. Select your WordPress database from the list on the left.
  3. Locate and click on the “wp_posts” table (replace wp_ with your WordPress database prefix if it is different).
    List of databases
  4. You will see a list of all your posts. Find the post you are interested in and look for the corresponding ID in the “ID” column.
    Id

Using Functions.php (Developer Method) –

  1. If you are comfortable with the code, you can use the following code snippet in your theme’s functions.php file to display the ID of a post or page-
    function get_post_id() {
    global $post;
    return $post->ID;
    }
  2. Then, you can use the get_post_id() function wherever you need to display the post or page ID within your theme.

Was not it useful to you? We hope you understood it well. These methods should help you find the post IDs and page IDs in WordPress, depending on your level of expertise and preference. However, if you encounter any issues or have further queries; contact our support team at your earliest.

Dominos Search