Answer the question
In order to leave comments, you need to log in
How to fix the code for displaying tags without errors?
there is a code, and it works fine on product pages that have tags filled in. But if the tags are not filled, it raises an error. Please tell me what's wrong? what needs to be fixed?
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_product_loop_tags', 31 );
function woocommerce_product_loop_tags() {
global $post, $product;
$tag_count = sizeof( get_the_terms( $post->ID, 'product_tag' ) );
$idProducto=$product->id;
$product->get_title();
$product->get_tags( ', ', '<span class="tagged">' . _n( 'Tag:', 'Tags:', $tag_count, 'woocommerce' ) . ' ', '.</span>' );
$producto= wc_get_product( $idProducto );
$Titulo=$producto->get_title();
echo " ".$product->get_tags( ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', $tag_count, 'woocommerce' ) . ' ', '.</span>' );
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question