• Hi all,
    I have two loops on my ‘home’ page. The first one is suposed to show only one post, and the other loop is suposed to show all the other posts from 2-10. How do I code this?
    dl33

Viewing 1 replies (of 1 total)
  • Thread Starter dl33

    (@dl33)

    I now have this code:

    <?php get_header(); ?>
    <?php $i = 1; ?>
    <div class="firstpost"><!--First Post-->
    <?php rewind_posts(); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php if ( $i == 1 ) { ?>
    The first post
    <?php }?>
    <?php $i=$i+1; ?>
    <?php endwhile; ?>
    <?php else : ?>

    <?php _e('Sorry, no posts matched your criteria.'); ?>

    <?php endif; ?>
    </div>

    <div class="primary"><!--Other Posts-->
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php if ( $i > 1 ) { ?>
    All the other stuff
    <?php } ?><!-- End if i>1-->
    <?php $i=$i+1; ?>
    <?php endwhile; ?>
    <?php else : ?>

    <?php _e('Sorry, no posts matched your criteria.'); ?>

    <?php endif; ?>
    </div>

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    However, the first post appears twice. What am I doing wrong?

Viewing 1 replies (of 1 total)
  • The topic ‘Show only a cetain number of post in the loop (multiple loops)’ is closed to new replies.