SHARE
TWEET

WooCommerce: exclude category from catalog

pedronave Oct 21st, 2012 201 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter( 'parse_query', 'custom_parse_query' );
  2. function custom_parse_query( $q ) {
  3.  
  4.         if ( !$q->is_post_type_archive() ) return;
  5.         elseif (!is_admin()){ //important
  6.         $q->set( 'tax_query', array(array(
  7.                 'taxonomy' => 'product_cat',
  8.                 'field' => 'slug',
  9.                 'terms' => array( 'promocoes' ),
  10.                 'operator' => 'NOT IN'
  11.         )));}
  12.  
  13. remove_filter( 'parse_query', 'custom_parse_query' );
  14.  
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top