Right way to display a category WooCommerce image, without h... open

Right way to display a category WooCommerce image, without hook.

Copy the archive-product.php file from the WooCommerce plugin directory to the woocommerce folder in your theme’s root directory. Add the following code to them:

global $wp_query;
    $cat = $wp_query->get_queried_object();
    $thumbnail_id = get_term_meta($cat->term_id, 'thumbnail_id', true);
    $thumb_url =  wp_get_attachment_image_src( $thumbnail_id, 'thumbnail' );
    if ($thumb_url) {
        echo '<img src="' . $thumb_url[0] . '" width="150" height="150" alt="' . $cat->name . '" />';
    }
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation