Single Wordpress loop showing lastest couple posts and headlines for the rest


/ Published in: PHP
Save to your folder(s)

This example will display the full content of the five most recent posts, and just the headlines from the five before that.


Copy this code and paste it in your HTML
  1. <?php
  2. query_posts('showposts=10');
  3. $count = 1;
  4. ?>
  5. <?php while (have_posts()): the_post(); ?>
  6. <div class="post">
  7. <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  8. <?php if ($count < 5): ?>
  9. <?php the_content(); ?>
  10. <?php endif; ?>
  11. </div>
  12. <?php $count++; ?>
  13. </div>
  14. <?php endwhile; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.