Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More β
Sometimes you want to keep certain product categories hidden from your WooCommerce shop page. Instead of removing them, use this handy PHP snippet to filter them out easily.
Code to Filter Product Categories on Shop Page
function filter_shop_page_categories( $query ) {
if ( is_shop() ) {
$categories_to_hide = 'your-category-slug'; // Change this to the slug you want to exclude
$tax_query = (array) $query->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( $categories_to_hide ),
'operator' => 'NOT IN',
);
$query->set( 'tax_query', $tax_query );
}
}
add_action( 'woocommerce_product_query', 'filter_shop_page_categories' );
Things to Keep in Mind
You can find more advanced customization options in the WooCommerce query documentation. 
Search our archives or reach out to our team for solutions and expert advice.