Support

Account

Home Forums ACF PRO have_rows() not working Reply To: have_rows() not working

  • just to get sure:
    you check frontpage for a page/post/custom-post where you have some content filled at backend. either photo or text.

    <?php
    
    // check if the flexible content field has rows of data
    if( have_rows('travel_gallery') ):
    
         // loop through the rows of data
        while ( have_rows('travel_gallery') ) : the_row();
    
            if( get_row_layout() == 'travel_text_row' ){
              $get_travel_text = get_sub_field('travel_text');
              echo $get_travel_text;
              echo '<br>normally above should stand the text';
            }
    
            if( get_row_layout() == 'travel_photo_row' ){ 
              $get_travel_photo = get_sub_field('travel_photo');
              echo $get_travel_photo;
              echo '<br>normally above should come the image';
            }
    
        endwhile;
    
    else :
    
        // no layouts found
      echo 'no layouts found';
    
    endif;
    
    ?>

    your code look correct. but what is the result when you use mine instead?