Last n (2/3/4 etc.) posts in a separate container
-
Hello,
Is there any way to accomplish this in index.php
(I’m writing the output not the php)
<div id="container"> <div id=firstpost"></div> <div id="secondpost"></div> ... <div id="last-posts-container"> <div id="ninth"></div> <div id="tenth"></div> </div> <!-- End of last posts container --!> </div>
I want for example latest 5 posts to have a style (same style all latest 5 of them) and last 5 posts to have another style (same style all 5 of them). And I want the last 5 posts to be wrapped inside a div. I managed to accomplish the first part (to make the last five different from the latest 5) but I can’t seem to understand how can I set a div outside the loop in other to wrap around the last 5 posts.
I’m using this method (someone posted it on this forum ) ,now, but I’m open to any other method.
<?php if (have_posts()) : ?> <?php $post = $posts[0]; $c=0;?> <?php while (have_posts()) : the_post(); ?> <?php $c++; if( !$paged && $c == 1 or $c == 2 or $c == 3 or $c == 4 or $c == 5) :?> latest 5 posts html code <?php else :?> last 5 posts html code <?php endif;?> <?php endwhile; ?> <?php endif;?>
Thank you
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Last n (2/3/4 etc.) posts in a separate container’ is closed to new replies.