Reputation: 831
I have the following so far:
<?php $count = 0; while (have_posts()) : the_post(); $count++; ?>
<?php if ($count < 5) : ?>
//four posts here, all them wrapped in one div, these will also have different markup
<?php the_title();?>
<?php else : ?>
//remaining six posts here, all of them wrapped in one div, these will also have different markup
<?php the_title();?> blah
<?php the_excerpt();?>
<?php endif; ?>
<?php endwhile; ?>
I want to wrap the first 4 in a '<div class="top"></div>
' and the bottom 6, I want all of them wrapped in a '<div class="bottom"></div>
'
Any tips of how this can be done using the while loop would be greatly appreciated
Upvotes: 1
Views: 94
Reputation: 7746
Try the below snippet.
<?php
$count = 0;
while (have_posts()) : the_post(); $count++;
if ( $count == 1 ) echo '<div class="top">';
if ( $count > 5 ) echo '</div><div class="bottom">';
the_title();
if ( $count > 5 ) the_excerpt();
endwhile;
echo "</div>"
?>
Upvotes: 1
Reputation: 3161
This might help you.
<?php $count = 0; while (have_posts()) : the_post(); $count++; ?>
<?php if ($count < 5) : ?>
//four posts here, all them wrapped in one div, these will also have different markup
<div class="top">
<?php the_title();?>
</div>
<?php else : ?>
//remaining six posts here, all of them wrapped in one div, these will also have different markup
<div class="bottom">
<?php the_title();?> blah
<?php the_excerpt();?>
</div>
<?php endif; ?>
<?php endwhile; ?>
Upvotes: 0