Mundo Posted November 30, 2010 Share Posted November 30, 2010 This is for display purposes... Is there any way i can make my while loop do the following: <div class="1">$item1</div> <div class="2">$item2</div> <div class="break"></div> <div class="1">$item3</div> <div class="2">$item4</div> <div class="break"></div> <div class="1">$item5</div> <div class="2">$item6</div> <div class="break"></div> Really can't think of a nice, simple, elegant solution for this... Quote Link to comment Share on other sites More sharing options...
trq Posted November 30, 2010 Share Posted November 30, 2010 for ($i = 0; $i <= 20; $i++) { if ($i % 3 == 0) { echo "break"; } else { echo $i; } } Quote Link to comment Share on other sites More sharing options...
Mundo Posted November 30, 2010 Author Share Posted November 30, 2010 The problem there is im using Wordpress... So my code is: <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> // first iterations: <div class="1"> <h3><?=the_title()?></h3> <?=get('custompost_image')?> <?=get('custompost_blurb')?> </div> // second iterations <div class="2"> <h3><?=the_title()?></h3> <?=get('custompost_image')?> <?=get('custompost_blurb')?> </div> // third iterations <div class="break"></div> //reset back to 0... <?php endwhile; ?> If you get me? Quote Link to comment Share on other sites More sharing options...
trq Posted November 30, 2010 Share Posted November 30, 2010 No, I don't get you. $i=0; while (hasposts()) { if ($i % 3 == 0) { echo "break"; } else { echo $i; } $i++; } Whats the problem? Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted November 30, 2010 Share Posted November 30, 2010 There's nothing special about this wordpress code aside from the fact that it uses the colon syntax rather than the curly brace syntax. It only APPEARS to be custom wordpress code, when in reality it's just regular old PHP. Simply stick the relevant IF statements inside your loop here. -Dan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.