Add an ID column to the posts and pages lists, so you can find IDs for shortcodes and settings without hovering over links.
function nahnu_id_column( array $columns ): array {
return array_slice( $columns, 0, 1, true ) + [ 'nahnu_id' => 'ID' ] + array_slice( $columns, 1, null, true );
}
function nahnu_id_column_value( string $column, int $post_id ): void {
if ( 'nahnu_id' === $column ) {
echo (int) $post_id;
}
}
add_filter( 'manage_posts_columns', 'nahnu_id_column' );
add_filter( 'manage_pages_columns', 'nahnu_id_column' );
add_action( 'manage_posts_custom_column', 'nahnu_id_column_value', 10, 2 );
add_action( 'manage_pages_custom_column', 'nahnu_id_column_value', 10, 2 );
add_action( 'admin_head', function (): void {
echo '<style>.column-nahnu_id{width:60px}</style>';
} );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
Shortcodes, page builder settings and plugin options often ask for a post or page ID. WordPress only shows it in the edit link’s URL. This snippet adds an ID column to every post type list.
manage_posts_columns (all post types except pages) and manage_pages_columns add the column right after the checkbox. The matching _custom_column actions print the ID, and a line of CSS keeps the column narrow.
Open Posts → All Posts. An ID column should appear next to the titles.