i have create custom field (textfield) in woocommerce category, which im trying to get in home where i have display woocommerce category with thumbnails and name in loop, which lists all woocommerce category in home page, but im unable to display acf custom field create in category within this loop so that is easily display acf custom field with this category loop.
when i paste following code in woocommerce shop page (archive-product.php) i easily get acf custom field but when i paste same code in home page i get nothing.
<?php $product_cat_object = get_queried_object(); ?>
<?php the_field('custom_link', 'product_cat_' . $product_cat_object->term_id); ?>
Category loop code which i used for getting woocommerce category with thumbnail and title:
<?php
$prod_categories = get_terms( 'product_cat', array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1
));
foreach( $prod_categories as $prod_cat ) :
$cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true );
$cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id );
$term_link = get_term_link( $prod_cat, 'product_cat_' );
$term_id = get_queried_object()->term_id;
?>
<img src="<?php echo $cat_thumb_url; ?>" alt="" class="w-100 d-block"/>
<h4><?php echo $prod_cat->name; ?></h4>
<?php endforeach; wp_reset_query(); ?>
I need to display acf custom-field create in woocommerce category in this loop..
so, can anyone share the knowledge how can i do that……