• Resolved elanio

    (@elanio)


    I am trying to figure out why the infinitescroll is repeating the first page over and over and over.

    I am using a static front page and have built a custom query.

    <?php
    /*
    Template Name: Main
    */
    
    get_header(); 
    
    $paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
    
    // WP_Query arguments
    $args = array (
    	'post_type'              => array('post','post_bike'),
    	'pagination'             => true,
    	'posts_per_page'     => '10',
    	'order_by' 				 => 'date',
    	#'paged'					 => $paged,
    );
    
    // The Query
    $wp_query = new WP_Query( $args );
    
    #var_dump($wp_query->found_posts);
    
    // The Loop
    if ( $wp_query->have_posts() ) {
    		#var_dump($query);
    		$wp_query->the_post();
    		// do something
    		 include (TEMPLATEPATH . '/php/article-class.php' );
    		#get_template_part('/php/article-class', get_post_format());
    	}
    	echo'HERE IS NAV';
    	include (TEMPLATEPATH . '/inc/nav.php' );
    	echo'END NAV';
    } else {
    	// no posts found
    	echo "<h2>Not Found</h2>";
    }
    
    // Restore original Post Data
    wp_reset_postdata();
    
     get_footer(); ?>

    Any help is greatly appreciatd, this is driving me crazy.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter elanio

    (@elanio)

    Resolved.

    <?php
    /*
    Template Name: Main
    */
    
    get_header(); 
    
    $paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
    
    // WP_Query arguments
    $args = array (
    	'post_type'              => array('post','post_bike'),
    	'pagination'             => true,
    	'posts_per_page'         => '10',
    	'order_by' 				 => 'date',
    	'paged'					 => $paged,
    );
    
    // The Query
    $wp_query = new WP_Query( $args );
    
    // The Loop
    if ( $wp_query->have_posts() ) {
    	while ( $wp_query->have_posts() ) {
    		#var_dump($query);
    		$wp_query->the_post();
    		// do something
    		 include (TEMPLATEPATH . '/php/article-class.php' );
    		#get_template_part('/php/article-class', get_post_format());
    	}
    	echo'HERE IS NAV';
    	include (TEMPLATEPATH . '/inc/nav.php' );
    	echo'END NAV';
    } else {
    	// no posts found
    	echo "<h2>Not Found</h2>";
    }
    
    // Restore original Post Data
    wp_reset_postdata();
    
     get_footer(); ?>

    so it was just a typo? i have a script doing something similar and am trying to track it down as well

    Hi p.renee,

    I was just having a similar problem, when using infinite-scroll with wp_query. It turned out that pagination wasn’t working properly for my wp_query.

    Try turning off infinite-scroll and make sure that you can get to the older posts pages.

    I found this post very helpful; https://www.ads-software.com/support/topic/pagination-with-wp_query-and-custom-post-type

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘infinitescroll and wp_query is repeating posts’ is closed to new replies.