0

A newbe wp_query question: I set a wp_query as follows, but instead of 17 posts I only get the first 10 posts from the selected Category with ID=5. Is there an implicit paging directive on the results?

    $myPosts = new WP_Query(); 
    $args_posts = array('cat' => 5);
    $myPosts->query($args_posts);           
    while ($myPosts->have_posts()) : $myPosts->the_post();          
            ?>              
            <div class="post">                  
            <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
            <div class="cover"><a href="<?php the_permalink(); ?>" rel="bookmark,nofollow" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $img ?>&amp;h=80&amp;w=120&amp;zc=1" width="120" height="80" alt="<?php the_title(); ?>" /></a></div>
            <?php } ?>
            <p><?php the_excerpt(240, __('read more &raquo;')); ?></p>              
            </div>              
            <?php endwhile;             
    }
} 

?>

1
  • I found the argument $query = new WP_Quer('nopaging=true'); but I am not sure it works
    – p.a.
    Jul 17, 2012 at 12:15

1 Answer 1

2

If you want to get all the pages instead, you should add posts_per_page'=>-1 to your query

You can have a look at the Wordpress Codex http://codex.wordpress.org/Class_Reference/WP_Query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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