• Hi there,

    I’m trying to do some minor changes to the products images at the grid according to each category. I was told to work with custom template with taxonomy-product_cat-CATEGORY-SLUG.php

    For example: “apple” category thumbnail need to use ‘woocommerce_catalog’ class AND so does ‘banana’ and ‘lemon’ category. But categories not listed at the function will keep using ‘shop_catalog’ class to thumbnails.

    I’ve searched a lot and found out this function (already adapted with my fake categories)

    function woocommerce_template_loop_product_thumbnail() {
    if ( is_tax( ‘product_cat’, ‘apple’ ) ) {
    echo woocommerce_get_product_thumbnail( ‘woocommerce_catalog’ );
    } else {
    echo woocommerce_get_product_thumbnail();
    }
    if ( is_tax( ‘product_cat’, ‘banana’ ) ) {
    echo woocommerce_get_product_thumbnail( ‘woocommerce_catalog’ );
    }
    if ( is_tax( ‘product_cat’, ‘lemon’ ) ) {
    echo woocommerce_get_product_thumbnail( ‘woocommerce_catalog’ );
    }
    }

    It was successful in a way that it called the right class to the image, BUT it also duplicated the thumb of every product. Now each product has 2 thumbnails: one image has the default class ‘shop_catalog’ and the other image has the new class called ‘woocommerce_catalog’.

    THE QUESTION: How can I fix the thumbnail duplication or how can I improve this function so it will avoid the duplication.

    I’m not a php expert, and have already tried ‘elseif’ but it didnt worked.

    if you have a guess about it, please share it with me….:)

    https://wordpress.org/plugins/woocommerce/

The topic ‘Woocommerce – Using is_tax function for template customization’ is closed to new replies.