• For our project on the categoy page we need to exlcude the product from the child categories.

    This is working good: https://gist.github.com/ibndawood/17ade59c2f856a59e42a5ebf91fbb357

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

    ++++

    Only with this snippet activated the filtering at the category pages is not working anymore.

    Can you please check this?

Viewing 1 replies (of 1 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    Sorry, you are talking about plugin search results page or you need general solutions for categories pages?

    This forum related to Advanced Woo Search plugin.

    Regards

Viewing 1 replies (of 1 total)
  • The topic ‘WooCommerce – Exclude products from child categories’ is closed to new replies.