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
, taken from the <a href="https://codex.wordpress.org/Function_Reference/get_the_category" rel="nofollow">Wordpress documentation on
</a>; yet it doesn't seem to output anything at all
Here's a code that I've included in
Code:
mytheme/woocommerce/content-product.php
Code:
get_the_category()
Code:
<a href="<?php the_permalink(); ?>" class="titulo-insumo" title="<?php the_title(); ?>">
<?php the_title(); ?>
</a>
<div class="label-group"><!--Categories *should* be outputed here -->
<?php
$categories = get_the_category();
$separator = ' ';
$output = '';
if($categories){
foreach($categories as $category) {
$output .= '<a href="'.get_category_link( $category->term_id ).'" class="label bg-terciary" title="' . esc_attr( sprintf( __( "Ver todos los artículos en la categoría %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
}
echo trim($output, $separator);
}
?>
</div>