Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );

function custom_pre_get_posts_query( $q ) {

if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() ) {

$q->set( 'tax_query', array(array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'membership' ), // Don't display products in the membership category on the shop page
'operator' => 'NOT IN'

remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' );


I used the above code to exclude the membership category in the shop page. Its working on the shoppage but it display in the homepage i need to know how to exclude the particular category in all those page . Basic idea is to be download the products only for the membership. I added the membership as the seperate product category , Also i exclude that category from the shop page but it displaying in the homepage . I don't how to do this in the woocommerce plugin.

share|improve this question

2 Answers 2

Include it in your woocommerce-core-functions.php to hide that category on "Shop" Page in your woocommerce site.

share|improve this answer
Please some example code; it is hard to see what you mean. Thanks. –  toscho Mar 30 '13 at 18:54

I've developed a plugin that will help you doing it: http://www.wpworking.com/product/woocommerce-exclude-categories-pro/

Best Regards

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.