Created
September 4, 2017 07:52
-
-
Save Shininglow/9376386f1ad4d5cbed2fbdca9513f23a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment