Home › Forums › General Issues › Display selected relationship as a String › Reply To: Display selected relationship as a String
You need to move the get_field into the loop. You are performing this function outside the loop so the post ID is either wrong or non-existent when you call the function.
// ... code before query & loop
$args = array(
'post_type' => 'evento',
'post_status' => 'publish',
'posts_per_page' => '-1',
'meta_query' => array(
array(
'key' => 'fecha_del_evento',
'compare' => '>=',
'value' => $today,
),
),
'meta_key' => 'fecha_del_evento',
'orderby' => 'meta_value',
'order' => 'ASC',
);
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
// put your get_field call here
$artista_evento = get_field('artista_del_evento');
$today = current_time('Ymd');
// the rest of your template code ...
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc
— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.