Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

411
Views
Revise Ajax Code (GIT: Lauren Gray) to work with Custom Loops

I have been using this code from Lauren Gray:

https://gist.github.com/graylaurenm/86daa4f23aa8749c0933f72133ac7106

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 );
        add_action('genesis_entry_header','add_play_button');

        echo '<article class="' . $countClasses . implode( ' ', get_post_class() ) . '">'; // add column class
        do_action( 'genesis_entry_header' );
        echo '</article>';

        endwhile;
        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>';
        endif;
    endif;

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

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!