Forums

Two loops, how to offset 1 loop by 10 comments (on Page 2)? (2 posts)

  1. alessia_e
    Member
    Posted 1 year ago #

    Hello!

    I have two loops on my page (www.shalasrabbithole.com/blog) where you'll see the largest post on top is loop 1, and secondary horizontal posts are loop 2.

    How can I offset loop 1by 10 posts so that on PAGE 2 that top post is on the correct by countdown?

    My current code is:
    Loop 1
    `<?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // pagination
    query_posts( 'cat=-9,-10&showposts=1&posts_per_page=11&paged=' .$paged );
    if (have_posts()) :
    while (have_posts()) : the_post(); $category = get_the_category();
    ?>`

    Loop2 (with a little offsetting hack)

    <?php
    add_filter('post_limits', 'my_post_limit');
    
    ?>
    
    <?php
    global $myOffset;
    $myOffset = 1;
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('offset='.$myOffset.'&showposts=10'.'&paged='.$paged);
    ?>
    
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // pagination
    					query_posts( 'cat=-9,-10&posts_per_page=10&paged=' .$paged);
    					if (have_posts()) : $counter = 0;
    						while (have_posts()) : the_post(); $category = get_the_category();
    
    						if( $counter % 2 == 0 )
    							$end = "";
    						else
    							$end = "last";
    				?>

    Thank you.
    A.

  2. alessia_e
    Member
    Posted 1 year ago #

    Essentially, I'd like for it to look like this:

    Page1:

    MAIN POST (1)

    2 | 3
    4 | 5
    6 | 7
    8 | 9
    10| 11

    Page2:

    Mainpost (12)

    13 | 14
    15 | 16

    ...

    I have the second loop working well, but not the first one :*(

Topic Closed

This topic has been closed to new replies.

About this Topic