I'm trying to display the comment count above my comment list in
comments.php without the pings included. The
comments_number() function doesn't allow for displaying them separately (why?), so I need to access the
$wp_query object directly.
Several examples on the web show this being done like this:
<?php if ( have_comments() ) : global $wp_query; ?> <h3 id="comments"><?php echo count($wp_query->comments_by_type['comment']); ?> comments</h3> <ol class="commentlist"> <?php wp_list_comments('type=comment&callback=cleanr_theme_comment'); ?> </ol>
However, this doesn't work.
After experimenting, I discovered that I'm able to access the
$wp_query object after calling
wp_list_comments() (looking at the code, that function declares
$wp_query as global).
How can I access the
$wp_query object before calling
wp_list_comments(), so that I can gain access to the comment count without pings included?