Skip to content

Instantly share code, notes, and snippets.

@MarceloGlez
Last active July 13, 2021 17:20
Show Gist options
  • Save MarceloGlez/2ab1d1bff621facf8ff9c08e5c01fb4d to your computer and use it in GitHub Desktop.
Save MarceloGlez/2ab1d1bff621facf8ff9c08e5c01fb4d to your computer and use it in GitHub Desktop.
Añadir taxonomía categoría de producto en tienda en Woocommerce (Agregar líneas de código en function.php del child theme)
/*Añade taxonomía categoría a producto en Tienda*/
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) : ?>
<a href="<?php echo get_term_link( $term->slug, 'product_cat'); ?>" rel="tag" class="btn btn-primary btn-sm mb-4"><?php echo $term->name; ?></a>
<?php endforeach;
endif; ?>
</div>
<?php }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment