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?

    • skycube

    • January 10, 2019 at 10:25 pm

    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)

You must be logged in to reply to this topic.

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.