Support » Fixing WordPress » Remove All Product and Category Thumbnails from the shop page

  • Hi!

    I need assistance adjusting this function.php code so that it will remove all product and /category thumbnails from the shop page of my store. At present, it’s coded to remove products from specific categories on the shop page. My website isn’t live yet. At present, without this code, all images would show duplicate because I am already setting them up in specific albums. I only need them to appear on certain pages where I put them rather than everything appearing on the shop page by default.

    /**
     * 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 page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Remove All Product and Category Thumbnails from the shop page’ is closed to new replies.