There is a filter on my list-view page of my custom post type (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;
}
}
On the same page where i filter this posts i use get_posts()
and it gives me only filtered posts
but should return all posts
. How can i prevent filtering my posts
when i use get_posts()
function.