Quickly identify WordPress post and page IDs by adding a Post ID column to the admin lists. Useful for developers working with custom queries, Elementor templates, shortcodes, and plugin configurations. A lightweight PHP snippet with no additional plugin required.
Steps
- Add the PHP code to your child theme’s
functions.phpfile or use the Code Snippets plugin. - Save and activate the snippet.
- Go to WordPress Admin → Posts → All Posts or Pages → All Pages.
- You’ll see a new Post ID column displaying the ID of each post or page.
Hooks Used
manage_posts_columns— Adds the Post ID column to the posts list.manage_pages_columns— Adds the Post ID column to the pages list.manage_posts_custom_column— Displays the post ID in the posts list.manage_pages_custom_column— Displays the page ID in the pages list.
Type: WordPress Admin Customization
Output: A new Post ID column appears in the WordPress admin Posts and Pages lists, allowing you to identify content IDs at a glance.
Why use this snippet? It saves time when working with custom queries, Elementor templates, shortcodes, and plugin settings that require post or page IDs. You can find the ID without opening each item individually.
/**
* Display post IDs in the WordPress admin Posts and Pages lists.
*/
function wpfolks_add_post_id_column( $columns ) {
$columns['wpfolks_post_id'] = 'Post ID';
return $columns;
}
add_filter( 'manage_posts_columns', 'wpfolks_add_post_id_column' );
add_filter( 'manage_pages_columns', 'wpfolks_add_post_id_column' );
/**
* Display the post ID in the admin columns.
*/
function wpfolks_display_post_id_column( $column, $post_id ) {
if ( 'wpfolks_post_id' === $column ) {
echo esc_html( (string) $post_id );
}
}
add_action(
'manage_posts_custom_column',
'wpfolks_display_post_id_column',
10,
2
);
add_action(
'manage_pages_custom_column',
'wpfolks_display_post_id_column',
10,
2
);
Tested on
Reported by the author on October 12, 2026. WPFolks has not verified this.
