1. add_filter('pre_get_posts','better_editions_archive');
  2.  
  3. function better_editions_archive($query) {
  4.  
  5.         if ( $query->is_tax( 'edition', 6 ) && $query->is_main_query() ) {
  6.                 $query->set( 'post_type', array( 'post' ) );
  7.  
  8.                 $tax_query_args = array(
  9.                                 'relation' => 'AND',
  10.                                 array(
  11.                                         'taxonomy' => 'category',
  12.                                         'field' => 'id',
  13.                                         'terms' => array( 1, 2, 4, 5 )
  14.                                 ),
  15.                                 array(
  16.                                         'taxonomy' => 'edition',
  17.                                         'field' => 'id',
  18.                                         'terms' => array( 7, 8 ),
  19.                                         'operator' => 'NOT IN'
  20.                                 )
  21.                 );
  22.  
  23.                 $query->set( 'tax_query', $tax_query_args );
  24.         }
  25.  
  26.         return $query;
  27. }

Posted by functions.php at 12 Mar 2013, 08:21:49 Europe/Berlin
Language: php