Guest User

Untitled

a guest
Mar 21st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. add_action( 'pre_get_posts', array( $this,'function_pre_get_posts' ) );
  2.  
  3. function function_pre_get_posts(){
  4. // you can't use the query->set here for tax_query
  5. // as tax query has already been made
  6. // so you need to need add youself to any
  7. // existing tax query
  8. $tax_query = array(
  9. 'taxonomy' => 'tax_name',
  10. 'field' => 'slug',
  11. 'terms' => 'term_name',
  12. 'operator'=> 'IN' );
  13. $query->tax_query->queries[] = $tax_query;
  14. $query->query_vars['tax_query'] = $query->tax_query->queries;
  15. }
Add Comment
Please, Sign In to add comment