Need some kind of 'inner loop'
-
This problem is a little more complex than I thought. I’m trying (in WordPress) to output 3 <span> elements in each iteration of the loop.
However each <span> element needs to advance the loop to the next iteration (if that makes sense).
See here:
<?php $count = 0; ?> <?php if(have_posts()) : ?> <?php while(have_posts()) : the_post(); ?> <div class="divide"> <span> <a href="<?php the_permalink(); ?>"> <span class="icon-home"><img src="<?php bloginfo('template_url'); ?>/image/icon-home-01.png" alt="Property" /></span> <span class="content"><?php the_title(); ?></span> </a> </span> </div> <?php $count ++; ?> <?php endwhile; ?> <?php endif; ?>
There needs to be 3 <span> elements inside each <div class=”divide” /> element.
One thing I did try was to include a for loop inside ‘div.divide’ so that it output 3 of the <span> elements. But then I realised it simply output 3 of the same elements (e.g. all of the ‘the_title()’ fields were the same instead of advancing onto the next post).
Does anyone have an idea how I can achieve it? Hopefully that makes sense, but I’m having trouble explaining it!
- The topic ‘Need some kind of 'inner loop'’ is closed to new replies.