If you’re looking to get the total of Wordpress and Discourse comments for a single post, then get_comments_number() will work (i.e. it will return the sum of both).
If you’re looking to get a sum total of all comments on your site (not from a specific post), whether from Wordpress or Discourse, this is a somewhat subjective question. It depends what you mean by “all comments”. You’ll need to write a custom function for this, and would do if you were just counting Wordpress comments by themselves. You’d do something like this and use it in a shortcode or block
function count_all_comments() {
$wordpress_count = wp_count_comments();
$count = $wordpress_count->approved;
$query_args = array(
'post_status' => 'publish',
);
$query = new WP_Query($query_args);
if ( $query->have_posts() ) {
while( $query->have_posts() ) {
$query->the_post();
$count += intval( get_post_meta( get_the_ID(), 'discourse_comments_count', true ) );
}
}
return $count;
}
(I just wrote this on the fly so please test it before you use it
)
Note that I’ve chosen to return the approved Wordpress comment count and the count of Discourse comments on published posts. There are other choices you could make there about what qualifies for your count.