Всем привет! Возникла проблема при выводе меток для всех категорий. Есть код, но он выводит метки для текущего товара:
function woocom_tags_list(){
$output = array();
// get an array of the WP_Term objects for a defined product ID
$terms = wp_get_post_terms( get_the_id(), 'product_tag' );
// Loop through each product tag for the current product
if( count($terms) > 0 ){
foreach($terms as $term){
$term_id = $term->term_id; // Product tag Id
$term_name = $term->name; // Product tag Name
$term_slug = $term->slug; // Product tag slug
$term_link = get_term_link( $term, 'product_tag' ); // Product tag link
// Set the product tag names in an array
$output[] = '<a href="'.$term_link.'">'.$term_name.'</a>';
}
// Set the array in a coma separated string of product tags for example
$output = implode( ', ', $output );
// Display the coma separated string of the product tags
return $output;
}
}
У меня есть id категории, нужно вывести все метки для нее и дочерних категорий. Как это можно сделать?