Advertisement
Guest User

Remove categories from onsale page

a guest
Aug 2nd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. add_action( 'woocommerce_product_query', 'custom_remove_category_from_sale_page',99 );
  2. function custom_remove_category_from_sale_page($q){
  3.     global $wp_query;
  4.         if($wp_query->is_sale_page) {
  5.             $taxquery = $q->get( 'tax_query' );
  6.             if ( ! is_array( $taxquery ) ) {
  7.                 $taxquery = array();
  8.             }
  9.             $taxquery []=
  10.             array(
  11.                 'taxonomy' => 'product_cat',
  12.                 'field' => 'term_id',
  13.                 'terms' => array( 12 ),
  14.                 'operator'=> 'NOT IN'
  15.             );
  16.             $q->set( 'tax_query', $taxquery );
  17.  
  18.         }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement