In this tutorial, I will explain how to remove products from a particular category from your shop page on frontend store. you have two option to implement the below code snippets with your WooCommerce store. First, you can create a separate plugin and add the below code.
Second, Open your functions.php file from your current theme’s folder and add below code at the end of the file. Below code will hide the products which belong to that product category.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?php if(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( 'PUT YOUR CATEGORY HERE' ), // Don't display products in the membership category on the shop page . For multiple category , separate it with comma. 'operator' =>; 'NOT IN' ))); } remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' ); } ?> |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: woocommerce plugin for wordpress tutorial, woocommerce plugin tutorial, woocommerce plugin wordpress tutorial, woocommerce template tutorial, woocommerce tutorial, woocommerce tutorials, wordpress woocommerce tutorial