Support

Account

Home Forums Add-ons Repeater Field A repeater in random order including select fields Reply To: A repeater in random order including select fields

  • Sorry Nuro, this is probably me being awful at explaining things.

    Say at the moment the code is pumping out:

    • Caption One <grey logo>
    • Caption Two <white logo>
    • Caption Three <grey logo>

    Three separate entries. Logo colour defined and fixed to the caption.

    I want it to pump out something like:

    • Caption Two <white logo>
    • Caption Three <grey logo>
    • Caption One <grey logo>

    OR

    • Caption Three <grey logo>
    • Caption One <grey logo>
    • Caption Two <white logo>

    OR any random order really. Notice the caption and the logo colour remain the same so it’s just jumbling up the order of the entries not the contents within each entry.

    So in essence something like:

    
    <?php if(get_field('slider_image')): ?>
      <RANDOM ORDER>
      <?php while(has_sub_field('slider_image')): ?>
        <?php the_sub_field('the_caption'); ?>
        <img src="<?php bloginfo('template_directory'); ?>/logo_<?php if(get_sub_field('logo_colour') == "White") { echo 'white'; } else { echo 'grey'; }?>.png" />
      <?php endwhile; ?>
    <?php endif; ?>
    

    Flippin’ eck I’m terrible at this stuff.