Home › Forums › General Issues › Show the ACF field in WooCommerce Category inside the Shop page › Reply To: Show the ACF field in WooCommerce Category inside the Shop page
Hey John, thank you for helping me out with this.
Buddy of mine who’s more experienced in development helped me out already. And here was the final code being used now:
function sd_loop_product_cat_note() {
// Get the category terms
$terms = get_the_terms( $post->ID, 'product_cat' );
// Only proceed if there is at least 1 category
if ( $terms && ! is_wp_error( $terms ) ) {
// Get the first term
$first_term = $terms[0];
// Get the product note for that term
$sd_loop_item_suffix = get_field( 'sd_product_archive_suffix', 'product_cat_' . $first_term -> term_id );
// Output the product note
echo $sd_loop_item_suffix;
}
}
add_action( 'woocommerce_after_shop_loop_item', 'sd_loop_product_cat_note', 5 );
This code displays the needed ACF field value in the Shop loop and Category loop in my website. (^_^)
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.