php - How to change category thumbnail size in woocommerce -


with following code managed display featured categories title, description , thumbnail. when uploaded thumbnail, 500*500 in dimensation. when visit page see thumbnail being cropped 150*150.

<?php     $args_t = array(         'taxonomy'     => 'product_cat',         'include'      => array( 16, 15, 17 ),         'orderby' => 'meta_value',     );     $thirds_categories = get_categories( $args_t );     foreach ( $thirds_categories $cat ) {         if( $cat->category == 0 ) {             $cat_class = mb_strtolower($cat->name);             $image = wp_get_attachment_url( $thumbnail_id );             $cat_thumb_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );             $cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id );             $term_link = get_term_link( $cat, 'product_cat' );?>               <div class="categories_box">                     <a href="<?php echo $term_link; ?>">                         <img src="<?php echo $cat_thumb_url; ?>" alt="<?php echo $cat->name; ?>" />                         <h4> <?php echo $cat->name; ?> </h4>                         <p><?php echo $cat->description; ?> </p>                         <button>view products</button>                     </a>                 </div>        <?php }                               } wp_reset_query(); ?>  

how can change size of categorythumbnails?

it first time doing woocommerce. hope can help.

you should use wp_get_attachment_image_src(); getting different sizes of image. return array url, width, height , cropping mode of image. have try

$args_t = array(         'taxonomy'     => 'product_cat',         'include'      => array( 16, 15, 17 ),         'orderby' => 'meta_value',     );     $thirds_categories = get_categories( $args_t );     foreach ( $thirds_categories $cat ) {         if( $cat->category == 0 ) {             $cat_class = mb_strtolower($cat->name);             $image = wp_get_attachment_url( $thumbnail_id );             $cat_thumb_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );             $cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id );             $term_link = get_term_link( $cat, 'product_cat' );             $thmb = wp_get_attachment_image_src($cat_thumb_id, 'medium');              ?>               <div class="categories_box">                     <a href="<?php echo $term_link; ?>">                         <img src="<?php echo $thmb[0]; ?>" alt="<?php echo $cat->name; ?>" />                         <h4> <?php echo $cat->name; ?> </h4>                         <p><?php echo $cat->description; ?> </p>                         <button>view products</button>                     </a>                 </div>        <?php }                               } wp_reset_query(); 

let me know if need more assistance. thanks


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -