I’m making my own comment template (like this) and I need to know how can I get the comment and ping count for the current post, maybe using a fast database query or something like that?
Note that I can’t use count($comments)
or anything like that, because I’m not running the default comments_template()
function which gets all the comments from the database. Instead I’m pulling only the newest 10 comments using get_comments()
.
$post->comment_count
(apparently initialized by get_post) is close to what I’m looking for, but it counts both comments and pings 🙁
you can use this custom function in the functions.php of the theme:
this function give you the count of pingback, trackback, comments or all, example:
you can use the follow parameter for return the counter: comment, trackback, pingback, pings or all