Woocommerce - Display categories within the loop

admin

Administrator
Staff member
Is it posible to display the <em>product categories</em> right beneath the tile, within the WooCommerce loop?

Here's a code that I've included in
Code:
mytheme/woocommerce/content-product.php
, taken from the <a href="https://codex.wordpress.org/Function_Reference/get_the_category" rel="nofollow">Wordpress documentation on
Code:
get_the_category()
</a>; yet it doesn't seem to output anything at all

Code:
        &lt;a href="&lt;?php the_permalink(); ?&gt;" class="titulo-insumo" title="&lt;?php the_title(); ?&gt;"&gt;
            &lt;?php the_title(); ?&gt;
        &lt;/a&gt;
        &lt;div class="label-group"&gt;&lt;!--Categories *should* be outputed here --&gt;
        &lt;?php
        $categories = get_the_category();
        $separator = ' ';
        $output = '';
        if($categories){
                foreach($categories as $category) {
                        $output .= '&lt;a href="'.get_category_link( $category-&gt;term_id ).'" class="label bg-terciary" title="' . esc_attr( sprintf( __( "Ver todos los artículos en la categoría %s" ), $category-&gt;name ) ) . '"&gt;'.$category-&gt;cat_name.'&lt;/a&gt;'.$separator;
                }
        echo trim($output, $separator);
        }

        ?&gt;

        &lt;/div&gt;