Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'pre_get_posts', 'zed1_exclude_front_page_cats' );
- function zed1_exclude_front_page_cats( $query ) {
- // if this is not the main query on the page, do nothing
- if ( !$query->is_main_query() )
- return;
- // if this is meant to show cat-a, do nothing
- if ( $query->is_category( 'cat-a' ) )
- return;
- // if this is meant to show cat-b, do nothing
- if ( $query->is_category( 'cat-b' ) )
- return;
- // otherwise, exclude cat-a and cat-b
- $tax_query = array (
- array (
- 'taxonomy' => 'category',
- 'field' => 'slug',
- 'terms' => array( 'cat-a', 'cat-b' ),
- 'operator' => 'NOT IN'
- )
- );
- $query->set( 'tax_query', $tax_query );
- } // end zed1_exclude_front_page_cats
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement