在 Wordpress 中使用 wpdb 查询检索 post IS 的总评论
Retrive Total Comments by post ID using wpdb query in Wordpress
我有两个问题:
- 使用 wpbd 查询按 Post ID 计算评论总数(没有 Post 作者和儿童评论)?
- 使用 wpdb 查询通过 Post ID 获取最后 3 个评论作者(没有 Post 作者和子评论)?
如果你有任何想法,请帮助我。
试试这个 -
<?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);
?>
我有两个问题:
- 使用 wpbd 查询按 Post ID 计算评论总数(没有 Post 作者和儿童评论)?
- 使用 wpdb 查询通过 Post ID 获取最后 3 个评论作者(没有 Post 作者和子评论)?
如果你有任何想法,请帮助我。
试试这个 -
<?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);
?>