I am using Advanced Custom fields and i have made 2 custom field types one matches where a get all the matches and i use some custom fields here and one called predictions which i want to display them in front page using the followin query
<?php
$headlines = 0;
$headlines_lead = get_field('sixed_relationship','alpha_brief', false);
$args = array(
'posts_per_page' => 4,
'offset' => 0,
'post_type' => array('analysis_stoiximatos', 'printed_post'),
'post__in' => $headlines_lead,
'post_status' => 'publish',
'orderby' => 'post__in'
);
?>
<?php $banner_query2 = new WP_Query( $args ); ?>
<?php
?>
<div class="central_main_area">
<h1>matches </h1>
<?php
$entos_edras_omada = get_field('entos_edras_omada');
?>
<?php if( $banner_query2->have_posts() ): ?>
<ul>
<?php while ( $banner_query2->have_posts() ) : $banner_query2->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<?php the_title();
setup_postdata( $args );
global $post;
var_dump(the_field( 'entos_edras_omada', get_the_id() ));
?>
</a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<section class="oloi_oi_agones" id="oloi_oi_agones">
</section>
the problen is that i get the title of each match BUT the field returns null….
2
Answers
Because it is relationship custom fields it needs another loop inside
You shouldn’t need to setup_postdata when you’re within the loop. I’m not sure that I understand
$headlines_lead = get_field('sixed_relationship','alpha_brief', false);
This looks incorrect to me. What kind of field is this? I’m guessing a relationship field and you’re trying to get an array output of post IDs, correct?Try this: