Hello, I created a Custom Post Type “Products”. Every product page is built via ACF blocks I registered (not a template page). Now, I want to loop some fields of those blocks in a single page with a loop. For doing that I used a Post Object block with which I can select the custom posts but in in the code of this page I can’t get the fields of the single product I need.
Here is the code:
$post_object = get_field('products'); // this is the Post Object block
if( $post_object ): ?>
<?php foreach( $post_object as $post ): ?>
<?php setup_postdata($post); ?>
<div class="p-product-thumb col-md-3 col-sm-6 col-6">
<a href="<?php the_permalink($post->ID); ?>">// I can get this
<div class="p-name"><?php the_field('product_name', $post->ID); ?> // I cannot get this </div>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
Anyone can help?
Thanks a lot,