“我的自定义帖子类型(works)”的“我的列表视图”页面上有一个筛选器
add_action( \'pre_get_posts\', array($this, \'exclude_category\') );
public function exclude_category( $query){
if( is_admin() && isset( $_GET[\'cta_filter\']) && ! empty( $_GET[\'cta_filter\'] ) )
{
$term = sanitize_text_field( $_GET[\'cta_filter\'] );
$query->tax_query->queries[] = array(
\'taxonomy\' => \'cta_tax\',
\'field\' => \'slug\',
\'terms\' => array( $term ),
\'operator\' => \'IN\'
);
$query->query_vars[\'tax_query\'] = $query->tax_query->queries;
}
}
在我筛选我使用的帖子的同一页上get_posts()
它只给我过滤posts
但应该返回所有posts
. 如何防止筛选posts
当我使用get_posts()
作用