I am creating a custom page to list all the product (taxonomy=product_cat) sub-categories with the ACF fields i have created.
I tried googling for solutions but all i can get is the_field('<>');
but when I am calling this it is not showing any value from the custom fields is WYSIWYG
<?php
$parentid = get_queried_object_id();
$args = array(
'parent' => 68,
'hierarchical' => 1,
'show_option_none' => '',
'hide_empty' => 0,
);
$terms = get_terms( 'product_cat', $args );
if ( $terms ) {
foreach ( $terms as $term ) {
var_dump($term);
echo '<div class="row expand-blocks"><div class="col-md-3">
<h3 class="category_name">'.$term->name.'</h3>';
woocommerce_subcategory_thumbnail( $term );
echo'</div> <div class="col-md-9 category_description"><p class="readmoretoggle">'.$term->description.'</p> <div class="row category_full_description"><div class="">';
echo '<div class="col-md-6"><div class="nutrition_value ">';
//need to show below
the_field('nutrition_value_per_one_cup', '107');
echo '</div></div> <div class="col-md-6"><div class="useful_value ">';
//need to show below
the_field('useful_for_body_parts');
echo '</div> </div>';
}
}
?>
I expect the html output for the fields
You can use reference on this page. https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/
//where $term = term object you get in foreach loop
the_field('nutrition_value_per_one_cup', $term);// display the value itself
or
echo get_field('nutrition_value_per_one_cup', $term);// need to echo or print the value.