Adding an email column to a Custom Post Types Admin Screen?

May be you can try this:

add_filter('manage_edit-movie_columns', 'custom_add_new_columns');
function custom_add_new_columns( $columns ){
    $columns['author_email'] = 'Email';
    return $columns;
}
add_action('manage_movie_posts_custom_column', 'custom_manage_new_columns', 10, 2);
function custom_manage_new_columns( $column_name, $id ){
    if ('author_email'==$column_name){
     $current_item = get_post($id);
     $author_id = $current_item->post_author;
     $author_email = get_the_author_meta( 'user_email', $author_id);
     echo '<a href="https://wordpress.stackexchange.com/questions/158706/mailto:".$author_email.'">'.$author_email.'</a>';
    }
}

Here, I have used custom post type movie. You need to replace movie word in hooks with your custom post type name.

For example, if your CPT is flower, hooks should be manage_edit-flower_columns and manage_flower_posts_custom_column.

First function adds heading of columns in the table. Second function adds content of the column according to the current post.

Leave a Comment