Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WooCommerce - 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_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
if ( $image ) {
echo '<img src="' . $image . '" alt="' . $cat->name . '" />';

This comment has been minimized.

Copy link

@lesmimis lesmimis commented Mar 23, 2014


it worked very well on woocommerce before 2.1 update. There is no longer a file functions.php.
Do you know where I can paste the code now, with the latest version of woocommerce?

Thank you for your answer.


This comment has been minimized.

Copy link

@fredmat fredmat commented Apr 18, 2014

A good way to do is to create a woocommerce.php in your theme and put all functions related to your shop there.
After in your functions.php of your theme:

require(get_template_directory() . '/woocommerce.php');

Hope it helps


This comment has been minimized.

Copy link

@morktron morktron commented Aug 19, 2014

This works fine in a child themes function.php file. The issue is that the image is outside of the .term-description div. This is generated by wc-template-functions.php line 476. Is there any way to add the image inside the containing div?

Otherwise it will require a lot of extra CSS to position the image relative to the container responsively.


This comment has been minimized.

Copy link

@tiknius tiknius commented Sep 21, 2015

Hi, how this code can be edited so parent category image is also displayed when viewing child categories? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment