I know how to count comment per post, user and in total but i am
having problems getting the total amount of comments post in a specific post type.
I guess i can loop trough all the posts and count each one
comments but i am looking for something faster and less
resource expensive
Appreciate your help
I got this so far (i think this is a bad way but i might be wrong):
/*** ALL COMMENTS COUNT BY POST TYPE ***/
function countCptCommentsTotal() {
// FAQ ARGS
$faqStatsArgs = array(
'post_type' => 'some_post_type',
'post_status' => 'publish',
'posts_per_page' => -1
);
$faqstats_query = new WP_Query($faqStatsArgs);
// THE LOOP
$allAnswers = 0;
while ($faqstats_query->have_posts()) {
$faqstats_query->the_post();
$curfaqid = get_the_ID();
$allAnswers = $allAnswers + countPostComments($curfaqid);
}
wp_reset_query();
return $allAnswers;
}