Additional Admin Columns: Post ID and Featured Image in the Post List
WordPress provides powerful customization options to streamline post management tasks. By adding post IDs and featured images to the admin post list column, administrators can quickly identify posts and enhance the user experience within the WordPress dashboard.
To include post IDs and featured images in the admin post list column, follow these steps in functions.php:
1. Use the manage_posts_columns() in functions.php file of your WordPress theme
Use the manage_posts_columns()
function to define new columns for the post list in the admin panel. Here’s an example of how to add columns for Post ID and Featured Image:
function custom_post_columns($columns){
$columns['post_id'] = 'Post ID';
$columns['featured_image'] = 'Featured Image';
return $columns;
}
add_filter('manage_posts_columns', 'custom_post_columns');
2. Next, populate the newly created columns with data
Use the manage_posts_custom_column
action hook to display the Post ID and Featured Image information:
function custom_post_column_data($column, $post_id){
if ($column === 'post_id') {
echo $post_id;
}
if ($column === 'featured_image') {
echo get_the_post_thumbnail($post_id, 'thumbnail');
}
}
add_action('manage_posts_custom_column', 'custom_post_column_data', 10, 2);
By implementing the above code in your theme’s functions.php file, the admin post list will now display additional columns for Post ID and Featured Image, offering administrators valuable insights and visual cues for efficient post management.
Integrating post IDs and featured images into the admin post list column enhances post management capabilities, allowing administrators to quickly identify and organize content within the WordPress dashboard. This customization not only improves workflow efficiency but also provides a more visually engaging experience for users interacting with the WordPress backend.