WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

OK, so I've read like 20 different articles about using a while loop inside another while loop, but still can't get this to work, and I'm about to burst from frustration.

My scenario: using the Advanced Custom Fields plugin along with the WP Coda Slider. My goal is to display a small gallery of images (that are loaded via the ACF plugin, on a custom post type) inside a Coda Slider.

The images in the ACF are also using the Repeater addon for ACF. This requires the use of a while loop to output the images.

Facts: parent field for images: portfolio-images field key for images: image

php that ACF says will display the images:

 <?php while(the_repeater_field('portfolio-images')): ?>
 <a href="<?php the_sub_field('link'); ?>">
 <img src="<?php the_sub_field('image'); ?>" alt="image" />
 <?php endwhile; ?>

I'm already running this loop for the WP Coda Slider:


            <div id="post-<?php the_ID(); ?>" <?php post_class('panel'); ?>>
                <div class="panel-wrapper">
                    <div id="package-tagline-container" class="container_24">
                        <div class="bracket grid_1">{</div>
                            <div id="page-tagline" class="grid_16">
                                <h6><?php the_field('tagline'); ?></h6>
                        <div class="bracket grid_1">}</div>
                        <div id="package-title" class="grid_6">
                            <h4 class="title"><?php the_title(); ?></h4>
                    </div><!-- #package-tagline-container -->

                        <?php the_content(); ?>

                </div> <!-- .panel-wrapper -->
            </div> <!-- .panel -->

         <?php endwhile; else:
     wp_reset_query(); ?>

I don't know what else to try at this point. Any help is very appreciated. Thanks.

share|improve this question

I would create a custom query for each nested loop and loop on its post data. Similar to what is written about here.

You will probably need to save the post global to a temporary variable so it can be set back ( setup_postdata() ) at the end of the nested look.

share|improve this answer
I am concerned about site performance with this approach, if you have many nested loops. – Jonnybojangles Nov 3 '11 at 21:21

What version of WP Coda Slider are you using? Are you using the short code or template tag to insert the slider?

The plugin works with nested loops inserted in the post with a shortcode. The normal gallery shortcode works fine.

BTW: I am the author of the plugin and it needs to be updated to use some of the newer WP API.

share|improve this answer
hi chris, thanks for responding. i am using the latest version of the Coda Slider via the template tag. the plugin works great btw, its just trying to add this gallery now that's giving me some trouble. any suggestions are appreciated. – jedifunk Nov 8 '11 at 14:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.