• Hello,

    I have a blog page that has a couple of loops (loop A and loop B). I have a do_not_duplicate line in loop B. And loop A is only running in my first page of my blog. My problem is this:

    First page of my blog: Loop A gives me posts number 1,2,3,4. Loop B, because of the do_not_duplicate line, gives me 5,6,7,8,9,10,11,12,13,14. That’s my blog page. Just what I want.

    Second page in my blog: When I press older posts (2nd page), I will get in loop B posts 11,12,13,14,15,16,17,18,19,20 and nothing in loop A as it is not running here. So I will get a repetition of 11,12,13,14 posts in the 2nd page of my blog. I would like to get the posts from 14 to 23, so I don’t get any repetition.

    1.- Loop number A is:

    if ( is_home() && ! is_paged() ) {
    $args_alj = array(
    		'cat' => 64,
    		'posts_per_page' => 4,
    		'orderby' => rand,
    		);
    $queryb = new WP_Query( $args_alj );
    while ( $queryb->have_posts() ) : $queryb->the_post();
    $do_not_duplicate[] = $post->ID;
    get_template_part( 'template-parts/content-front', get_post_format() );
    endwhile;
    }

    2.- Loop B is:

    $args_lat = array(
    		'post__not_in' => $do_not_duplicate,
    		'paged' => get_query_var('paged'),
    		);
    $latest = new WP_Query( $args_lat );
    while ( $latest->have_posts() ) : $latest->the_post();		get_template_part( 'template-parts/content', get_post_format() );
    endwhile;

  • The topic ‘Repeating some of my posts in second blog page’ is closed to new replies.