Support

Account

Home Forums ACF PRO Problems with Select field and get_sub_field('columns') Reply To: Problems with Select field and get_sub_field('columns')

  • I fixed it. For anyone else struggling, ths worked for me:

    <?php
    
    if( have_rows('text_area') ) :
      while ( have_rows('text_area') ) : the_row();
        if( get_row_layout() == 'text' ) :
    
          if(get_sub_field('columns') == "1") : ?>
    
            <div>
              <?php the_sub_field('first_column_text') ;?>
            </div>
    
          <?php elseif(get_sub_field('columns') == "2") : ?>
    
            <div>
              <?php the_sub_field('first_column_text'); ?>
              <?php the_sub_field('second_column_text'); ?>
            </div>
    
          <?php endif;
    
        endif; //get_row_layout
    
      endwhile; //have_rows
    
    endif; //have_rows
    
    ?>