Skip to content

Instantly share code, notes, and snippets.

@MarceloGlez
Last active July 13, 2021 17:20
Show Gist options
  • Save MarceloGlez/386dbe3e858de8d5a98fd1d3adf44eed to your computer and use it in GitHub Desktop.
Save MarceloGlez/386dbe3e858de8d5a98fd1d3adf44eed to your computer and use it in GitHub Desktop.
Añadir taxonomía categoría de producto en página de productos sin enlace a categorías en Woocommerce (Agregar líneas de código en function.php del child theme)
/*Añade taxonomía categoria a producto en Tienda sin enlace a categorias*/
add_action('woocommerce_shop_loop_item_title', 'add_tags_and_category', 15);
function add_tags_and_category() { ?>
<div 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; ?>
</div>
<?php }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment