2

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

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');
1

If you change manage_edit-post_columns to manage_posts_columns in your code snippet, then it should hide the comment column for all post types (appart from the page post type) within the WP_Posts_List_Table src. You might want to check if the column array key isset first, before unsetting it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.