How to get the total comment count for a custom comment type in WordPress

I am using a custom comment type ‘blog’ when inserting comments in WordPress. For example:

wp_insert_comment( array(
    'comment_post_ID'      => $args['post_id'],
    'comment_content'      => wp_filter_post_kses( $args['content'] ),
    'comment_type'         => 'blog',
    'user_id'              => $args['user']->ID,
    'comment_author'       => $args['user']->display_name,
    'comment_author_email' => $args['user']->user_email,
    'comment_author_url'   => $args['user']->user_url,
) );

How can I get the comment count for each post? The following doesn’t work for me because it displays the count for comments of type ‘comment’. I need to display the total count for comments of type ‘blog’.

wp_count_comments( $post_id );

Related posts

Leave a Reply

2 comments