pedronave

WooCommerce: exclude category from catalog

Oct 21st, 2012
235
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×