Woocommerce product category image

Orange Gorilla
40 Posts
Orange Gorilla posted this 18 April 2021

Hi,

I would like to show the productcategory image just below the header. Like a banner.
Is there a way to do this by adding a CMS block for example?

I can't use add controle because it's just can be just in a content & sidebars block. I want to show it above (see atttachment place of red line).

Hi, I would like to show the productcategory image just below the header. Like a banner. Is there a way to do this by adding a CMS block for example? I can't use add controle because it's just can be just in a content & sidebars block. I want to show it above (see atttachment place of red line).
Vote to pay developers attention to this features or issue.
2 Comments
Order By: Standard | Newest
Orange Gorilla
40 Posts
Orange Gorilla posted this 20 April 2021

Someone? I would like to have a banner on each category/shop page. But can't figure out how to create this situation.

Someone? I would like to have a banner on each category/shop page. But can't figure out how to create this situation.
Support Team
Support Team posted this 21 April 2021

Hello,

Try adding this code to your CMS Code control:

 <?php $prod_categories = get_terms( 'product_cat', array(
        'orderby'    => 'name',
        'order'      => 'ASC',
        'hide_empty' => true
    ));

    foreach( $prod_categories as $prod_cat ) :
        $cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true );
        $cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id );
        $term_link = get_term_link( $prod_cat, 'product_cat' );?>

        <a href="<?php echo $term_link; ?>"><img src="<?php echo $cat_thumb_url; ?>" alt="<?php echo $prod_cat->name; ?>" /></a>

    <?php endforeach; wp_reset_query();

?>

Gina
Themler Support

Hello, Try adding this code to your CMS Code control: <?php $prod_categories = get_terms( 'product_cat', array( 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true )); foreach( $prod_categories as $prod_cat ) : $cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true ); $cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id ); $term_link = get_term_link( $prod_cat, 'product_cat' );?> <a href="<?php echo $term_link; ?>"><img src="<?php echo $cat_thumb_url; ?>" alt="<?php echo $prod_cat->name; ?>" /></a> <?php endforeach; wp_reset_query(); ?> Gina Themler Support
You must log in or register to leave comments