• Resolved pils87

    (@pils87)


    Hello!

    I allready found out how i can do multiple loops but now i want the first loop to show the last 2 posts, and the second loop to show post 3 to 10.

    <?php
    get_header(); 
    
    php rewind_posts();
    ?>
    
    <?php
    if (have_posts()) :
    global $more;
    $more = 0;
    while (have_posts()) : the_post();
    ?>
    
    <!-- First 2 posts -->
    
    <?php
    endwhile;
    endif;
    ?>
    
    <?php
    if (have_posts()) :
    while (have_posts()) : the_post();
    ?>
    
    <!-- Post 3 to 10 -->
    
    <?php
    endwhile;
    endif; 
    
    get_footer();
    ?>

    Somebody who can give me a hint in the right direction?

    Thanks! Pils

Viewing 2 replies - 1 through 2 (of 2 total)
  • Use offset

    <?php
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 2,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    $args=array(
      'offset' => 2,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 8,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    Thread Starter pils87

    (@pils87)

    Sorry for the late response! This Works! Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Posts in multiple loops (First 2 and 3-10)’ is closed to new replies.