I have been using this code from Lauren Gray:


on my Wordpress site, and it works really well for the homepage and archive loops - any that are built into the main wp_Query. However I have created a new custom WP_Query and the AJAX doesn't work, it says "no more articles found" on click of the button...

$loop = new WP_Query( array( 
            'post_type' => 'post', 
            'paged' => $paged, 
            'posts_per_page' => 10 
        ) );

    if ( $loop->have_posts() ) :
        while ( $loop->have_posts() ) : $loop->the_post(); 

        remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
        remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
        remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
        add_action( 'genesis_entry_header', 'genesis_do_post_image', 8 );
        echo '<article class="' . $countClasses . implode( ' ', get_post_class() ) . '">'; // add column class
        do_action( 'genesis_entry_header' );
        echo '</article>';

        if (  $loop->max_num_pages > 1 ) : 
            echo '<div class="load-more"><a class="load-more-button" id="'.$pageType.'"><i class="fa fa-caret-down" aria-hidden="true"></i> Load More</a></div>';

What edits do I need to make to her code so it works with a custom loop like above?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.