By default, the comment column shows the number of approved comments. I would like to either:

  • Change this to the number of comments pending approval, OR;
  • Create a new column with the number of comments pending approval

Can this be achieved?


Add following code in your theme's functions.php.

// To add extra column in column headers
add_filter('manage_posts_columns', 'bs_event_table_head');
function bs_event_table_head( $defaults ) {
    $defaults['pending_comments']  = 'Pending Comments';
    return $defaults;

// To add data in column for each post.
add_action( 'manage_posts_custom_column', 'bs_event_table_content', 10, 2 );
function bs_event_table_content( $column_name, $post_id ) {

    if ($column_name == 'pending_comments') {

        // getting comments' counts
        $comments_count = wp_count_comments();
        $url = admin_url('edit-comments.php?comment_status=moderated&p=');
        echo '<a href="'.$url.$post_id.'" title="'.$comments_count->moderated.' pending" class="post-com-count"><span class="comment-count">'.$comments_count->moderated.'</span></a>';



// To make column sortable
add_filter( 'manage_edit-post_sortable_columns', 'bs_event_table_sorting' );
function bs_event_table_sorting( $columns ) {
    $columns['pending_comments'] = 'pending_comments';
    return $columns;

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.