Support

Account

Home Forums Add-ons Repeater Field Nested repeater error

Solved

Nested repeater error

  • Im trying to use a repeater to show a number of images.
    It throws the following error:
    Parse error: syntax error, unexpected ‘[‘ in file x at line x etc.

    The error is located at the [‘url’] and [‘alt’] tags. If I remove these, a little test shows that there’s an array with the right objects in it.

    <?php if( have_rows('villa_description') ){
         while ( have_rows('villa_description') ) : the_row(); ?>
         
         <ul>
          <?php if(get_sub_field ('slideshow_images')) {
              while ( has_sub_field('slideshow_images') ){ ?>
                  <li>
                      <a href="<?php echo get_sub_field('image')['url'] ?>">
                          <img src="<?php echo get_sub_field('image')['url'] ?>" alt="<?php echo get_sub_field('image')['alt'] ?>" />
                      </a>
                 </li>
          <?php 
              } 
         } ?>
    </ul>
    <?php endwhile;
    } ?>

    The problem is that it doesn’t work on the server.
    It works fine on localhost though.

  • Hi,
    Kindly check to ensure that you are running the same version of php on both environment.

    You may also want to store the image object in array variable before accessing it for ease of debugging in your case.

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

The topic ‘Nested repeater error’ is closed to new replies.