If you have added custom post types to your WordPress site, you might be interested in adding custom columns to the admin are for that post type. Here’s how you can do that:
function wpsnippets_custom_columns_header( $columns ) {
$columns['custom_column'] = __( 'Custom Column', 'wpsnippets' );
return $columns;
}
add_filter( 'manage_{$post_type}_posts_columns', 'wpsnippets_custom_columns_header' );
function wpsnippets_custom_columns_content( $column_name, $post_id ) {
if ( $column_name == 'custom_column' ) {
// Add your custom column content here.
echo 'Custom Column Content';
}
}
add_action( 'manage_{$post_type}_posts_custom_column', 'wpsnippets_custom_columns_content', 10, 2 );
Make sure to replace the $post_type
in manage_{$post_type}_posts_columns
and manage_{$post_type}_posts_custom_column
, where $post_type
is the slug of your custom post type.