Support » Plugin: Advanced Woo Search » Can you exclude certain categories from the search, eg Uncategorized

  • Resolved Emer


    Just installed this and really like it so far but I have 2 categories excluded from viewing the shop and Product Catalog dropdown for Uncategorised and another but they are showing in this. Trying to figure out a function to hide them. Any help greatly appreciated.

    Thanks in advanced.

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



    You can use PRO plugin version for this. Its has feature to exclude any products by id, taxonomy or attribute right inside settings page.

    Also you can try to use following code snippet:

    add_filter( 'aws_exclude_products', 'aws_exclude_products' );
    function aws_exclude_products( $filtered ) {
        $args = array(
            'posts_per_page'      => -1,
            'fields'              => 'ids',
            'post_type'           => 'product',
            'post_status'         => 'publish',
            'ignore_sticky_posts' => true,
            'suppress_filters'    => true,
            'no_found_rows'       => 1,
            'orderby'             => 'ID',
            'order'               => 'DESC',
            'lang'                => '',
            'tax_query'           => array(
                    'taxonomy'            => 'product_cat',
                    'field'               => 'id',
                    'terms'               => array( %CATEGORIES_IDS% ),
                    'operator'            => 'IN',
                    'include_children' => true
        $posts = get_posts( $args );
        foreach( $posts as $post_id ) {
            $filtered[] = $post_id;
        return $filtered;

    change %CATEGORIES_IDS% with IDs of categories that you want exclude from the search.


Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.