Display category image and featured image on Archive
-
This is a solution for those who need to add image for Shop or Category
/** * Display category image on category archive */ add_action('woocommerce_archive_description', 'woocommerce_category_image', 2); function woocommerce_category_image() { if (is_product_category()) { global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_term_meta($cat->term_id, 'thumbnail_id', true); $image = wp_get_attachment_url($thumbnail_id); if ($image) { echo '<div style="margin-bottom: 20px;">'; echo '<img src="' . $image . '" />name . '"/>'; echo '</div>'; } } }
/** * Display shop image on archive */ add_action('woocommerce_archive_description', 'woocommerce_shop_feature_image', 2); function woocommerce_shop_feature_image() { if (is_shop()) { echo '<div style="margin-bottom: 20px;">'; echo get_the_post_thumbnail(get_option('woocommerce_shop_page_id')); echo '</div>'; } }
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Display category image and featured image on Archive’ is closed to new replies.