Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MarceloGlez/140370bac609e2bc8bba505c5d9aebd7 to your computer and use it in GitHub Desktop.
Save MarceloGlez/140370bac609e2bc8bba505c5d9aebd7 to your computer and use it in GitHub Desktop.
Añade categoría a producto en Tienda en Woocommerce (Agregar líneas de código en function.php del child theme)
/*Añade categoría a producto en Tienda*/
add_action('woocommerce_shop_loop_item_title', 'add_tags_and_category', 15);
function add_tags_and_category() { ?>
<span class="tags">
<?php $product_terms = get_the_terms( get_the_ID(), 'product_cat');
if( $product_terms && ! is_wp_error( $product_terms ) ) :
foreach( $product_terms as $term) : ?>
<span><?php echo $term->name; ?></span>
<?php endforeach;
endif; ?>
</span>
<?php }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment