Forums › Forums › Search & Filter Pro › Exclude IDs not working in WooCommerce results
- This topic has 8 replies, 2 voices, and was last updated 6 years, 3 months ago by Trevor.
-
Anonymous(Private) August 7, 2018 at 2:59 am #184682
I have a S&F WooCommerce search form and have excluded certain product categories. This removes them from the filtering but the product category thumbnails still show for 2 of the excluded categories.
I have tried to exclude them in the with the Advanced settings for the Taxonomy and also in the Tags, Categories & Taxonomies tab (globally). Neither removes the two category thumbnails.
Trevor(Private) August 8, 2018 at 12:38 pm #184849Hi
The actual display of the category tiles is a separate query from ours, so our filter does not affect it. I excluded the categories from the search, so that works, but you will need to find a hook in WooCommerce to exclude the categories from that category grid. Something like this maybe:
https://www.engagewp.com/remove-categories-woocommerce-product-category-widget/
Anonymous(Private) August 8, 2018 at 10:37 pm #184891Okay, got it. Didn’t realise S&F wasn’t doing the query at that stage.
For anyone else looking for this, this is what worked in the end.
/** * Hide Categories from WooCommerce Shop Page */ add_filter( 'woocommerce_product_subcategories_args', 'custom_woocommerce_product_subcategories_args' ); function custom_woocommerce_product_subcategories_args( $args ) { $args['exclude'] = array('139','140', '132', '331', '330'); // Insert the product category IDs you wish to exclude return $args; }
Based on this: https://mikejolley.com/2018/02/07/woocommerce-3-3-hide-uncategorized-category-from-the-shop-page-on-the-frontend/
-
AuthorPosts