您可以尝试以下方法,必须在循环中使用:
<?php
// type = comment will only get "real" comments, no ping-/trackbacks
$comments = get_comments(array(\'type\' => \'comment\'));
$threads = 0;
foreach($comments as $comment) {
// if the comment has no parent, it´s the first of a thread
if($comment->parent == \'\') { $threads++; }
}
switch($threads) {
case 0: echo "There are no comments so far."; break;
case 1: echo "There is one thread..."; break;
default: echo "There are \'.$threads.\' comment threads going on."; break;
}
?>