我的插件通过我自己的WP_Comment_Query在帖子开头检索了一些注释。我保存这些ID,以便我可以更改WP_Comment_Query请求,而不是获取这些ID。
当我使用 pre_get_comments 挂钩隐藏这些已经获取的ID时,它们也会在每个帖子开头的第一个查询中隐藏。它无视这一点。
$this->loader->add_action( 'pre_get_comments', $plugin_public, 'hide_the_comments' );
public function hide_the_comments( $comment_query ) {
$comment_query->query_vars['comment__not_in'] = $the_ids_to_hide;
}
我们如何才能定位底部请求,就像post循环的is_main_query()一样?
答案 0 :(得分:1)
private $count = 0;
答案 1 :(得分:0)