Support

Account

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. (^_^)