Support

Account

Home Forums General Issues have_rows and the_sub_field not working together?

Helping

have_rows and the_sub_field not working together?

  • I’m trying to get this working following the documentation but it still doesn’t work. Ay suggestions?

    
    if (get_field('departures', get_the_ID())) {
            while( have_rows('departures') ): the_row();
                    // NOT WORKING
                    echo the_sub_field('departure_date');
                    // WORKING
                    $a = the_row();
                    echo $a['departure_date'];
            endwhile;
    }
    

    Example data:

    
    [{"departure_date":"01-12-2020"]}[{"departure_date":"07-12-2020"]}
    
  • do not use echo when using the_… functions

    instead of echo the_sub_field('departure_date');

    use the_sub_field('departure_date');

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘have_rows and the_sub_field not working together?’ is closed to new replies.