I’m using pre_get_posts and looking for a way to exclude posts in the main query. I’m using query_vars to query posts from a specific category and looking for a solution to exclude those posts in the main query. My code: // function to setup query_vars function ctrl_dly_podcast( $query_vars ){ $query_vars[] = ‘ctrl_podcasts_status’; return $query_vars; } […]
Categories
How to ignore posts in pre_get_posts?
- Post author By Marcia D.
- Post date November 26, 2020
- No Comments on How to ignore posts in pre_get_posts?
- Tags 'ctrl_dly_podcast' ); function index_first_post( $query_vars ){ $query_vars[] = 'index_first_post'; return $query_vars; } add_filter( 'qu, 'field' => 'slug', 'first_video' ); function rest_posts( $query_vars ){ $query_vars[] = 'posts_the_rest'; return $query_vars; } add_filter( 'query_vars', 'index_first_post' ); function first_video( $query_vars ){ $query_vars[] = '1st_video'; return $query_vars; } add_filter( 'query_vars', 'opby_query' );, 'operator' => 'NOT IN', 'operator'=> 'IN'))); $query->set('posts_per_page', 'operator'=> 'NOT IN'))); $query->set('posts_per_page', 'rest_posts' ); //the pre_get_posts function function opby_query( $query ) { if( isset( $query->query_vars['ctrl_podcasts_status'] )) {, 'terms' => array( 'podcast-control-daily' ), 'terms' => array( 'video' ), $query->query_vars['ctrl_podcasts_status']); $query->set('posts_per_page', $query->query_vars['index_first_post'], 1); } if( isset( $query->query_vars['1st_video'] )) { $query->set('tax_query', 1); } if( isset( $query->query_vars['index_first_post'] )) { $query->set('tax_query', 1); }; // the part I'm having problems with if( isset( $query->query_vars['posts_the_rest'] )) { $query->set('offset', 15); } return $query; } add_action( 'pre_get_posts', array('taxonomy' => 'post_format', array($query->query_vars['1st_video'], array(array('taxonomy' => 'category', I'm using pre_get_posts and looking for a way to exclude posts in the main query. I'm using query_vars to query posts from a specific categor