How many posts per page, in a normal loop, are too many to start affecting performance on the server?

I guess the answer could be "it depends" but I just want to know an approximate number (10? 100? 1000?) that will not affect noticeably the page load. Consider only receiving the HTML document, leaving aside loading images, etc.

(In case it is relevant each post includes the post title, the thumbnail, and possibly an excerpt.)

  • 2
    Performance would be based on your server but if I were to guess on average, 200-500 is probably a solid upper limit. – Howdy_McGee Jan 20 '17 at 21:21
  • 1
    @Howdy_McGee Yes, However if you are using a more advanced server such as LiteSpeed i would safely go for 1000, since i tried it on local and it worked fine for me. – Jack Johansson Jan 20 '17 at 21:41
  • The result set has to fit in memory, it depends on how much memory you have. – Milo Jan 20 '17 at 22:31
  • 1
    Your best bet is to use an ajax loader, and base on the current X posts, find the next set of X posts and display them. That would be my best advice. Using processing power for something like loading a 1000 or so posts is ludicrous. – Cam Jan 21 '17 at 0:24

You need a js file..

Then call using js a stream

function ajaxStreamCall(){
        data : {
            action: 'get_stream',
            offset : +++ //you will need to find a method to offset from your current posts

        success: function(obj){

        url: "/wp-admin/admin-ajax.php"

You will need to find what your offset is, maybe just count your current stream (posts) and tell it to offset that many..

BTW.. If you are lost already, just find a plugin to do this, im not giving 100% how to, you will need some Wordpress / Ajax knowledge

Next in functions

add_action( 'wp_ajax_get_stream', 'stream' );
add_action( 'wp_ajax_nopriv_get_stream', 'stream' );
function stream(){
  $post_offset = $_POST['offset'];
$args = array( 'numberposts' => '10','offset' =>$post_offset );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
        printf( '<li><a href="%1$s">%2$s</a></li>',
             esc_url( get_permalink( $recent['ID'] ) ),
             apply_filters( 'the_title', $recent['post_title'], $recent['ID'] )

Now just use jQuery to append this to the end. Again.. This is just an idea of how to do this. If you have questions let me know. Hopefully this sets you in the right direction.

  • Also, this is custom! You will need to modify your index or page file to do this... If this is off a theme, use a child theme to do this. – Cam Jan 21 '17 at 0:41
  • Thanks @Cam , Im using Ajax to call the single post in a Dialog. But I was wondering about performance limitations on doing a loop. – Alvaro Jan 21 '17 at 8:58
  • #questionreadingfail , I think you will note that your performance using Ajax wont be an issue. – Cam Jan 23 '17 at 16:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.