Resource
/
Display Content IDs in WordPress

Details

Category
Utilities & Scripts
Last Updated
Mar 7, 2026
Creator
Zayn Hamza

Overview

This snippet adds an ID column to WordPress admin tables so you can quickly see the unique ID of posts, pages, custom post types, and taxonomies directly in the dashboard.

WordPress assigns a unique ID to every item, but it is normally hidden in the admin interface. Seeing these IDs can be useful when working with custom code, plugins, queries, or integrations that require referencing a specific item by its ID.

Setup

00

Add External Scripts

Copy & paste the scripts before the </body> tag of your project. If you added them before for another setup, skip this step.

00

Add HTML

Place the code in an HTML widget or add it through Elementor → Custom Code (before the closing </body> tag) either globally or only on selected pages.

00

Add Custom CSS

Paste the code through the page or site settings, or add it via Elementor → Custom Code (before </body>) for broader use.

00

Add Custom Javascript

Paste the script through Elementor → Custom Code (set to load after </body>) for site-wide or page-specific loading.

00

Add Custom PHP

Place the PHP snippet in your theme’s functions.php file or add it using a code snippets plugin to enable the logic.

// Column width
add_action('admin_head', function(){
  echo '<style>.column-ou_id{width:60px}</style>';
});

function ou_add_id_column($cols){
  $cols['ou_id'] = 'ID';
  return $cols;
}

function ou_render_id_column($col,$id){
  if($col === 'ou_id') echo $id;
}

// Post types
add_action('admin_init', function(){
  foreach(get_post_types([], 'names') as $pt){
    add_filter("manage_{$pt}_posts_columns",'ou_add_id_column');
    add_action("manage_{$pt}_posts_custom_column",'ou_render_id_column',10,2);
  }
});

// Taxonomies
add_action('admin_init', function(){
  foreach(get_taxonomies([], 'names') as $tax){
    add_filter("manage_edit-{$tax}_columns",'ou_add_id_column');
    add_filter("manage_{$tax}_custom_column",function($v,$c,$id){
      if($c==='ou_id') return $id;
      return $v;
    },10,3);
  }
});
00

Publish and preview live

Some solutions only work on the live site. Always publish and test after each change, as results may not appear in the editor.