Woocommerce and categories...

Hello folk :slight_smile:
I cannot succeed in creating a categories zone in my site.
When I check the option “categorie” and allow one ID, the children come with :slight_smile:
I don’t want to.
And when I check several products and categories plus slugs, it doesn’t work as I want it.

I want to be able just to select the cat. I need as in the pink box :
http://www.monuniverspapier.fr/autre-accueil/

I want to have the same (as in pink) but be able to select 4 cat. and not more…
And the wc-box in Beaver allows different ways but not this one.

The fist row you’ll see is a selection of on ID (in one column) e.g 81 but with its sub-categories…

Thanks for your help :slight_smile:
Frédérique

I’ve tried this in my functions.php file but no succeeded in hiding the sub-cat.

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’);

Hey Frédérique,

Sorry but I’m having a bit of a problem understanding what you’re trying to do. Also, the page you linked above goes to a 404. Could you check?

Ben