Hi, JodieRD.
If you’re comfortable with copying and tweaking PHP, try using this snippet I found at WPExplorer.com into your theme’s functions.php file:
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
2
3
function custom_pre_get_posts_query( $q ) {
4
5
if ( ! $q->is_main_query() ) return;
6
if ( ! $q->is_post_type_archive() ) return;
7
8
if ( ! is_admin() && is_shop() && ! is_user_logged_in() ) {
9
10
$q->set( 'tax_query', array(array(
11
'taxonomy' => 'product_cat',
12
'field' => 'slug',
13
'terms' => array( 'color', 'flavor', 'spices', 'vanilla' ), // Don't display products in these categories on the shop page
14
'operator' => 'NOT IN'
15
)));
16
17
}
18
19
remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
20
21
}
Caveat: I haven’t tried this out myself; and it may just remove specific product categories.