hiding subcategory products from parent category
-
Hi
I was running this function to hide subcategory products from parent categories.
function exclude_product_cat_children($wp_query) { if ( isset ( $wp_query->query_vars['product_cat'] ) && $wp_query->is_main_query()) { $wp_query->set('tax_query', array( array ( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $wp_query->query_vars['product_cat'], 'include_children' => false ) ) ); } } add_filter('pre_get_posts', 'exclude_product_cat_children');
But since the last update is has not been working.
anyone have an idea why it isn’t?Thanks!
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘hiding subcategory products from parent category’ is closed to new replies.