Image default

Show Category in WooCommerce Product Loop

An online store in WooCommerce, show the name of the category in the product loop (in the last products of the home page and the category page), next to the name and the price.

I think there are some templates that already foresee it, but that was not the case, so I had to look for some function that would add it.

I leave it to you in case someone needs the same thing and this way the search is saved 😉

 remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
 add_action( 'woocommerce_shop_loop_item_title', 'DPW_woo_loop_product_title', 10 );

function DPW_woo_loop_product_title() {

$terms = get_the_terms( $post->ID, 'product_cat' );
 if ( $terms && ! is_wp_error( $terms ) ) :
 //only displayed if the product has at least one category
 $cat_links = array();
 foreach ( $terms as $term ) {
 $cat_links[] = $term->name;
 $on_cat = join( " ", $cat_links );
<?php endif;
 echo '' . get_the_title() . '';

What it does is replace the standard WooCommerce template to show the product title in the loop and replace it with a custom one that includes the array of product categories, so if it belongs to more than one, all will be displayed.

Related posts

How to Add Variable Products in WooCommerce


How to Display Category Wise Product in WooCommerce


How To Hide or Disable Add To Cart Button In WooCommerce Store