Pluggable function to only display images for parent categories
<?php | |
function woocommerce_subcategory_thumbnail( $category ) { | |
global $woocommerce; | |
// Modification: don't show the image for subcategories | |
if ( $category->parent ) return; | |
$small_thumbnail_size = apply_filters( 'single_product_small_thumbnail_size', 'shop_catalog' ); | |
$image_width = $woocommerce->get_image_size( 'shop_catalog_image_width' ); | |
$image_height = $woocommerce->get_image_size( 'shop_catalog_image_height' ); | |
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true ); | |
if ( $thumbnail_id ) { | |
$image = wp_get_attachment_image_src( $thumbnail_id, $small_thumbnail_size ); | |
$image = $image[0]; | |
} else { | |
$image = woocommerce_placeholder_img_src(); | |
} | |
if ( $image ) | |
echo '<img src="' . $image . '" alt="' . $category->name . '" width="' . $image_width . '" height="' . $image_height . '" />'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment