Displaying comment and ping counts separately
-
I’m trying to display the comment count above my comment list in
comments.phpwithout the pings included. Thecomments_number()function doesn’t allow for displaying them separately (why?), so I need to access the$wp_queryobject 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_queryobject after callingwp_list_comments()(looking at the code, that function declares$wp_queryas global).How can I access the
$wp_queryobject before callingwp_list_comments(), so that I can gain access to the comment count without pings included?
The topic ‘Displaying comment and ping counts separately’ is closed to new replies.