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.

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

1 Answer 1

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. –  Ahmad 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.