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've fixed my initial problem but I'd like to know what I was doing wrong.

<?php 
    $args = array( 
        'post_type' => 'page',
        'post__not_in' => array( $post->ID ),
        'post_parent' => '43',
        'post_count' => '3',
    );
    $my_related_posts = new WP_Query( $args );
?>

Displays 4 results, where I expected 3. I fixed the problem by doing:

<?php 
    $args = array( 
        'post_type' => 'page',
        'post__not_in' => array( $post->ID ),
        'post_parent' => '43',
        'post_count' => '3',
        'posts_per_page' => '3'
    );
    $my_related_posts = new WP_Query( $args );
?>

But what was I doing wrong? Changing post_count seemed to have little or no effect. Thanks

share|improve this question

1 Answer 1

up vote 3 down vote accepted

post_count is not a parameter of WP_Query argument.

post_count is a property used to get the number of posts being displayed. For example, echo $my_related_posts->post_count; will display the number of posts being displayed.

share|improve this answer
    
Ahhhhhh.... Is posts_per_page what I should be using for what I'm trying to do? Thanks! –  Djave Feb 22 '13 at 12:14
    
Yes, posts_per_page is the number of posts you want to be returned from that query. –  RRikesh Feb 22 '13 at 12:16

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.