Remove “Comment” column in all post-types

I just want to remove Comment’s column in all post-types and in a single function

enter image description here

My current function , Have to do each post-type like this :

function remove_post_columns($columns) {
    unset($columns['comments']);
    return $columns;
}
add_filter('manage_edit-post_columns','remove_post_columns',10,1);

function remove_page_columns($columns) {
    unset($columns['comments']);
    return $columns;
}
add_filter('manage_edit-page_columns','remove_page_columns',10,1);

Possible to do in a single function and for future post-types ?

2 Answers
2

I got an alternative :

This will not just hiding but disabling also

function disable_comments() {
    $post_types = get_post_types();
    foreach ($post_types as $post_type) {
        if(post_type_supports($post_type,'comments')) {
            remove_post_type_support($post_type,'comments');
            remove_post_type_support($post_type,'trackbacks');
        }
    }
}
add_action('admin_init','disable_comments');

Leave a Comment