Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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;             
    }
} 

?>

share|improve this question
    
I found the argument $query = new WP_Quer('nopaging=true'); but I am not sure it works –  p.a. Jul 17 '12 at 12:15
add comment

1 Answer

up vote 2 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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