WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using this code to get posts of specific taxonomy. It displays 10 posts by default. How can I set my own limit?

<?php 
    $count = 1; 
    $the_query = new WP_Query( array( 'brand' => 'sony-vaio' ) );
    while ($the_query->have_posts()) : $the_query->the_post();
    ?>
share|improve this question
up vote 5 down vote accepted

To display 5 posts, say, use posts_per_page. See the Codex.

$the_query = new WP_Query( array( 'brand' => 'sony-vaio','posts_per_page'=>5 ) );
share|improve this answer
    
thanks a lot, it worked all right. – Allen Jan 15 '12 at 18:33

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.