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!
We've just released ACF 5.12.3 with a security fix to prevent arbitrary file uploads to forms with ACF fields.— Advanced Custom Fields (@wp_acf) July 14, 2022
Now that we've released this update, we recommend updating your sites as soon as possible.
© 2022 Advanced Custom Fields.