I'm using this snippet to add column with posts ID:
/** Admin column with ID **/
function posts_columns_id($defaults){
$defaults['wp_post_id'] = __('ID');
return $defaults;
}
add_filter('manage_posts_columns', 'posts_columns_id', 5);
function posts_custom_id_columns($column_name, $id){
if($column_name === 'wp_post_id') {
echo $id;
}
}
add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2);
// width
function posts_columns_id_width() {
echo '<style type="text/css">.column-wp_post_id { text-align: left; width:60px !important; overflow:hidden }</style>';
}
add_action('admin_head', 'posts_columns_id_width');
Works fine except my CPT where column is visible, but ID's not; and except pages, where column is not visible at all,
How to deal with it?