我认为一个很好的方法就是使用comment__not_in
的参数get_comments()
作用发送当前在Ajax请求中显示的注释的ID,并在comment__not_in
论点例如,您可以将这些ID发送为comment__not_in[]
查询变量(数组格式):
$comment_not_in = $_REQUEST[\'comment__not_in\'];
$comments = get_comments(
array(
\'post_id\' => $_REQUEST[\'post_id\'],
\'status\' => \'approve\',
\'order\' => \'ASC\',
\'comment__not_in\' => $comment_not_in,
\'number\' => 1000
)
);
此外,我建议清理数据。由于ID应该是整数,我们可以这样做:
$comment_not_in = array_map( \'intval\', $_REQUEST[\'comment__not_in\'] );
$comments = get_comments(
array(
\'post_id\' => (int) $_REQUEST[\'post_id\'],
\'status\' => \'approve\',
\'order\' => \'ASC\',
\'comment__not_in\' => $comment_not_in,
\'number\' => 1000
)
);