What exactly i want to know is how do i get my categories like in the picture. (The food types thumbnails.) I have a WordPress site with the Maya Shop theme which is based on Woo Commerce. I tried every which way i could from the menu and i hadn't managed to do it. Also tried to fiddle a little bit with the Short code to no avail. I am new to this an i want to keep it as simple as possible. Do i have to write php code for some files or can i do it simpler than that?
That's not good answer. get_category_link() is not appropriate function to use for custom taxonomy. Function get_term_link() is what we need here.
<?php
$prod_categories = get_terms( 'product_cat', array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1
));
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(); ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With