• Resolved ce2mla

    (@ce2mla)


    Hi
    I have a custom loop running on a static front page.

    When I have the plugin set on ‘load more button’ or ‘infinite scroll’ I can only load page 2’s items. Getting to the bottom of the list of page 2 items there is no button etc to load the next pages worth of items.

    If I have the plugin set to ‘pagination’ or disabled I can get to the third page without a problem.

    Unfortunately the site is only on localhost at the moment. but here is the loop:

    <ul class="media-list media-list-sales">
    
      <?php
      $paged = (get_query_var('page')) ? get_query_var('page') : 1;
      // WP_Query arguments
      $args = array (
        'post_type'              => array( 'business' ),
        'nopaging'               => false,
        'posts_per_page'         => '5',
        'paged' => $paged
      );
    
      // The Query
      $query = new WP_Query( $args );
      // The Loop
      if ( $query->have_posts() ) {
        while ( $query->have_posts() ) {
          $query->the_post();
          // do something
          // some vars for the loop
          $businessLink = get_the_permalink();
          $distressed = get_post_meta( get_the_ID(), 'distressed_business');
          if (!is_user_logged_in() && 'yes' == $distressed[0]) {
            $businessLink = get_bloginfo('url')."/join-as-advisor";
          }
    
          if ('yes' == $distressed[0]) {
            echo '<li class="media media-distressed">';
          }else{
            echo '<li class="media">';
          }
            echo '<div class="media-left">';
              /* stripped code out to save space */
          echo '</li>';
    
        }
      } else {
        // no posts found
      }
    
      echo '<nav class="nav-below">';
        //adds pagination
        $big = 999999999; // need an unlikely integer
        echo paginate_links( array(
        	'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
        	'format' => '?paged=%#%',
        	'current' => max( 1, get_query_var('page') ),
        	'total' => $query->max_num_pages
        ) );
      echo '</nav>';
    
      // Restore original Post Data
      wp_reset_postdata();
        ?>
    
    </ul><!--media-list-->

    Any light you can shed on this would be great, thanks

    https://www.ads-software.com/plugins/malinky-ajax-pagination/

Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘'load more' only fires once’ is closed to new replies.