Quantcast
Channel: WordPress.org Forums » [WooCommerce] Support
Viewing all articles
Browse latest Browse all 104029

vicky081 on "How to exclude the particular category from the woocommerce plugin?"

$
0
0
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.

http://wordpress.org/extend/plugins/woocommerce/


Viewing all articles
Browse latest Browse all 104029

Trending Articles