我有两个问题:
- 统计评论总数(不含作者)儿童评论)通过Post ID使用wpbd查询?
- 获取最近3个评论作者(不包括帖子作者&儿童评论)通过Post ID使用wpdb查询?
试试这个-
<?php $args = array(
'order' => 'DESC',
'parent' => '0',
'number' => '',
'post_id' => get_the_ID(),
'status' => 'approve', //hold, approve, all
'count' => true
);
$total_number_of_comments = get_comments( $args );
echo $total_number_of_comments;
?>
<?php $args = array(
'order' => 'DESC',
'parent' => '0',
'number' => '3',
'post_id' => get_the_ID(),
'status' => 'approve', //hold, approve, all
'count' => false
);
$last_three_comments = get_comments( $args );
print_r($last_three_comments);
?>