Add extra columns in WordPress admin custom post types


add_filter( ‘manage_{custom_post_type}_posts_columns’, ‘set_custom_post_type_edit_columns’ );
function set_custom_post_type_edit_columns($columns){
$columns[‘user_mail’] = __( ‘Email’, ‘your_text_domain’ );
return $columns;
}
add_action( ‘manage_{custom_post_type}_posts_custom_column’ , ‘custom_post_type_column’, 10, 2 );
function custom_post_type_column( $column, $post_id ) {
switch ( $column ) {
case ‘user_mail’ :
echo get_post_meta( $post_id , ‘user_mail’ , true );
break;
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s