Title: loop inside the loop?
Last modified: August 19, 2016

---

# loop inside the loop?

 *  [forcetwelve](https://wordpress.org/support/users/forcetwelve/)
 * (@forcetwelve)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/loop-inside-the-loop/)
 * hi there guys
 * i can’t get my custom field image to display in my template. i need to have a
   loop inside a loop i think – but i’ll be buggered if i know where?? can anyone
   guide me as to how i should have this template structured? thx.
 * my code:
 * <?php get_header(); ?>
 *  <div id=”content” class=”clearfix”>
 *  <div id=”feature_wrapper”>
 *  <div id=”feature_sub”><?php include (ABSPATH . ‘/wp-content/plugins/wp-featured-
   content-slider/content-slider.php’); ?></div><!– feature_sub –>
 *  </div><!– feature_wrapper –>
 *  <div id=”left_column”>
 *  <?php the_content(); ?>
 *  </div><!– left_column –>
 *  <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
 *  <div id=”right_column”>
 *  <?php echo get_post_meta($post->ID, ‘right_image’, true); ?>
 *  </div><!– right_column –>
 *  <?php endwhile; else: ?>
 *  <?php endif; ?>
 *  </div><!– content –>
 * <?php get_footer(); ?>

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [forcetwelve](https://wordpress.org/support/users/forcetwelve/)
 * (@forcetwelve)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/loop-inside-the-loop/#post-1372033)
 * here’s the page in question: [http://www.ceresfoodconnect.org.au/test/the-story/](http://www.ceresfoodconnect.org.au/test/the-story/)
 *  Thread Starter [forcetwelve](https://wordpress.org/support/users/forcetwelve/)
 * (@forcetwelve)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/loop-inside-the-loop/#post-1372035)
 *     ```
       <?php get_header(); ?>
   
       	<div id="content" class="clearfix">
   
       			<div id="feature_wrapper">
   
       				<div id="feature_left"><?php wp_cycle(); ?></div><!-- feature left -->
   
       						<div id="box1" class="transparent_class">
       							<?php echo get_post_meta($post->ID, 'box1_image', true); ?>
       							<h3><?php echo get_post_meta($post->ID, 'box1_header', true); ?></h3>
       						</div><!-- box1 -->
   
       						<div id="box2" class="transparent_class">
       							<?php echo get_post_meta($post->ID, 'box2_image', true); ?>
       							<h3><?php echo get_post_meta($post->ID, 'box2_header', true); ?></h3>
       						</div><!-- box2 -->	
   
       			</div><!-- feature_wrapper -->
   
       					<div id="news_wrapper">
   
       						<h1>LATEST NEWS FROM CERES</h1>
       						<div class="line_big"></div><!-- line_big -->
       								<?php
       								$featuredPosts = new WP_Query();
       								$featuredPosts->query('category_name=news&showposts=2');
   
       								while($featuredPosts->have_posts()) :
       								$featuredPosts->the_post();?>
   
       							<div id="news_item">	
   
       								<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
       								<?php the_excerpt(); ?>
   
       							</div><!-- news_item -->
       								<?php endwhile; ?>
   
       					</div><!-- news_wrapper -->		
   
       					<?php if (have_posts()) : ?>
       					<?php while (have_posts()) : the_post(); ?>
   
       						<div id="column1">
       							<h1><?php echo get_post_meta($post->ID, 'column1_header', true); ?></h1>
       							<div class="line_column"></div><!-- line_column -->
       							<p class="details"><?php echo get_post_meta($post->ID, 'column1_text', true); ?></p>
       						</div><!-- column1 -->	
   
       						<div id="column2">
       							<h1>CERES INFO</h1>
       							<div class="line_column"></div><!-- line_column -->
       							<p class="details"><b>Location</b><br />
       							2030 Address St<br />
       							Brunswick 3088<br />
       							Victoria Australia<br /><br />
       							<b>Get in touch</b><br />
       							Telephone 03 9876 7666<br />
       							Fax 03 8765 7890<br />
       							info@foodconnect.org.au<br /><br />
       							<b>Opening Hours</b><br />
       							8:30 - 5:00 <br />
       							Monday to Friday</p>
       						</div><!-- column2 -->	
   
       			<?php endwhile; else: ?>
   
       			<?php endif; ?>
   
       	</div>
   
       <?php get_footer(); ?>
       ```
   
 *  Thread Starter [forcetwelve](https://wordpress.org/support/users/forcetwelve/)
 * (@forcetwelve)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/loop-inside-the-loop/#post-1372036)
 * that is my index template code – which works fine…

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘loop inside the loop?’ is closed to new replies.

 * 3 replies
 * 1 participant
 * Last reply from: [forcetwelve](https://wordpress.org/support/users/forcetwelve/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/loop-inside-the-loop/#post-1372036)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
