Hi!
This post is somewhat in reference to my previous thread https://theme.co/apex/forum/t/remove-products-from-woocommerce-shop-pages-integrity/47392 However, I have a partial solution. but need help adjusting the code so that it works for all products.
Without this code, any WooCommerce product that is created appears on the main shop page. I do not wish to have them appear in this way because I am also using Envira gallery and would like certain items to appear in certain areas only on specific pages.
With the code added to the functions file the separate product image does not appear. Here is the codeâŚ
/**
* Exclude products from a particular category on the shop page
*/
function custom_pre_get_posts_query( $q ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'melanin crown' ), // Don't display products in the hair products category on the shop page.
'operator' => 'NOT IN'
);
$q->set( 'tax_query', $tax_query );
}
add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );
add_filter( 'wc_stripe_show_payment_request_on_checkout', '__return_true' );
The website is not live yet so I will include login details in a secure note.