Steps
-
Add the PHP code to your child theme’s
functions.phpfile or the Code Snippets plugin. -
Save and activate the snippet.
-
Go to WordPress Admin → Posts → All Posts.
Hook Used
-
manage_posts_columns— Adds the Post ID column. -
manage_posts_custom_column— Displays each post’s ID.
Type: WordPress Admin Customization
Output: A Post ID column appears in the posts list, making it easy to identify individual posts.
Why use this snippet? Post IDs are useful when configuring shortcodes, custom queries, redirects, and other WordPress customizations.
function custom_add_post_id_column( $columns ) {
$columns['post_id'] = 'Post ID';
return $columns;
}
add_filter( 'manage_posts_columns', 'custom_add_post_id_column' );
function custom_display_post_id_column( $column, $post_id ) {
if ( 'post_id' === $column ) {
echo esc_html( (string) $post_id );
}
}
add_action( 'manage_posts_custom_column', 'custom_display_post_id_column', 10, 2 );
Tested on
Reported by the author on October 15, 2026. WPFolks has not verified this.
Not tested against WordPress 7.1.3. It may still work.