Last active
July 13, 2021 17:21
-
-
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)
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 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