Last active
July 13, 2021 17:20
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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