在Wordpress中使用wpdb查询按帖子ID检索总评论


Retrive Total Comments by post ID using wpdb query in Wordpress

我有两个问题:

  1. 统计评论总数(不含作者)儿童评论)通过Post ID使用wpbd查询?
  2. 获取最近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);
?>