• Hi guys,

    For the life of me I can’t see why posts_per_page is still only returning 5 posts even though I have set it to -1 to catch all posts within that category. There are over 60 of them!

    Any help will be appreciated.

    <?php
    $args = array( 'posts_per_page' => -1, 'offset'=> 0, 'category' => 6 );
    $lastposts = get_posts( $args );
    
    foreach ( $lastposts as $post ){
      setup_postdata( $post ); ?>
    	<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    
    <?php }
    
    ?>
Viewing 1 replies (of 1 total)
  • Thread Starter capitalalist

    (@capitalalist)

    As a quite commonly used function I’m surprised no one has an answer to this. I’ve been trying for days in vain to solve it. Just can’t work out why it only returns 5 results!

    Has anyone come across this before?

Viewing 1 replies (of 1 total)
  • The topic ‘posts_per_page not returning expected result’ is closed to new replies.