If you want to pre-approve your customers (such as in a trade-only shop) then you might want to disable the visibility of pricing as the ability for visitors to buy your products.

Catalog Visibility Options

The Catalog Visibility Options plugin will do this and also let you choose which user roles can see products and product categories.

Therefore, if you want to take a category out of the shop, use the plugin to do that.

PHP code

Otherwise there is this code that I saw on Business Bloomer but the code was in the comments, and is from Jonathan from Inspired Earth

function custom_pre_get_posts_query( $q ) { $tax_query = (array) $q->get( 'tax_query' ); $tax_query[] = array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => array( 'CATEGORY-TO-HIDE' ), // Don't display products in the this category on the shop page. 'operator' => 'NOT IN' ); $q->set( 'tax_query', $tax_query ); } add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );

Here is the raw code

Where to put the code

I use the Code Snippets plugin (it’s in the WordPress repository) to contain snippets of php.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.