I have nested categories in my website.
I created a custom Field in Woocommerce category and I tried to Add it in category loop. It shows only the term value of the current category page
add_action( 'woocommerce_after_subcategory_title', 'custom_add_cat_Min_price', 12);
function custom_add_cat_Min_price ($category) {
$prix_min_catt = get_term_meta(get_queried_object_id(), 'prix_min_cat', true);
$terms = get_the_terms( $post->ID, 'prix_min_cat' );
foreach ($terms as $term){
echo '<div class="prixminofcatg">'.$prix_min_catt.'</div>';
}
}
2
Answers
Thanks its working without Foreach
I think the problem is the scope of your function. You’ve passed the $category to your function, but haven’t used it. This gives you the ID of your category:
and from there, you should be able to extract the custom fields.