Hi,
So I have a problem fetching a post object and can’t seem to understand how to solve it. I have a custom post type called “News” where I have news articles. In one of these articles I want to fetch another post from another custom post type which is called “Match 1”. The Post object is setup in ACF but when I try to fetch the title within my article loop with the code below it just returns the News article heading over and over again, not even the correct heading.
<?php
$match_post = get_field('match');
if( $match_post ): ?>
<?php foreach( $match_post as $post ): ?>
<?php setup_postdata($post); ?>
<?php the_title(); ?>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
If I instead go with the following:
<?php
$featured_post = get_field('match');
$fieldone = the_field('date', $featured_post->ID);
if( $featured_post ): ?>
<h3><?php echo esc_html( $featured_post->post_title ); ?></h3>
<h3><?php echo esc_html( $fieldone ); ?></h3>
<?php endif; ?>
I get the fields from that post so it’s good. Unfortunately I have some subfields and repeaters which I’m not sure how to loop through 🙁