How to Show Post ID in WordPress

How to show post id in WordPress

There will come a time sooner or later when you will need to get post ID in WordPress. Below I will briefly explain how to view the ID of each post on WordPress. Posts, pages and any type of custom post in WordPress all have their own unique numeric ID assigned automatically by WordPress in the database to identify and distinguish them from one another. Behind the scenes, post IDs are used by queries for all kinds of things. You have three easy ways to view them without using any plugins.

  1. First method: edit your post and the post ID will appear in your browser’s address bar. This same thing applies for pages, custom post types etc.browser top address bar
  2. Second method: you can see the post ID at the bottom of the browser when you hover your mouse over a post.browser bottom bar
  3. Third method: Paste the following php code in your theme’s functions.php or in your custom plugin.
    • Log into your WordPress Admin interface.
    • Go to Appearance.
    • Go to Theme Editor.
    • In the right menu find functions.php
    • Copy and paste the code below at the end of functions.php
    • Publish.
add_filter('manage_posts_columns', 'posts_columns_id', 5);
    add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2);
    add_filter('manage_pages_columns', 'posts_columns_id', 5);
    add_action('manage_pages_custom_column', 'posts_custom_id_columns', 5, 2);
function posts_columns_id($defaults){
    $defaults['wps_post_id'] = __('ID');
    return $defaults;
function posts_custom_id_columns($column_name, $id){
    if($column_name === 'wps_post_id'){
            echo $id;

After you save it, return to your WordPress Dashboard and click All Posts; you will now be able to finally find your post IDs without installing any plugin.

wordpress how to show post ids

This post was updated on Friday / August 2nd, 2019 at 11:32 PM