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 working on my first WP site and am having some difficulty. In my theme's index.php page, I see the following code:

<?php 
query_posts(array(
  'category__not_in' => array($headline),
  'post__not_in' => $postnotin,
  'paged' => $paged,
  'numberposts' => 5
));
if ( have_posts() ): $postCount = 0; ?>
<?php while ( have_posts() ) : the_post(); $postCount++;?>
[more code....]

So - you see I'm trying to limit the number of posts on the home page to 5, which I thought was the default. Anyways, it is showing more than 5 and I can't seem to get it to work. I've tried "posts_per_page" without luck. If my theme is overwriting it, any ideas where that may be?

FWIW, I'm using the initiator theme by colorlabs

Thanks!!!

share|improve this question
    
numberposts is the old parameter, you should be using posts_per_page. Right now, I believe they are identical in function, but numberposts is depreciated, so you cannot count on it to be available with the next release of wordpress. –  m0r7if3r Apr 25 '12 at 1:41
    
Thanks, m0r7if3r. Updating it with posts_per_page doesn't work either. I have a feeling the theme is over writing it. I don't want to do some php counting hack but am about ready to... –  julie p Apr 25 '12 at 2:08
    
Have you checked the appropriate filters and actions? –  m0r7if3r Apr 25 '12 at 2:18
1  
This will get you started. You may just want to print_r( $wp_filter )` and look at everything, but that's gonna generate a massive list that may or may not be of use to you. –  m0r7if3r Apr 25 '12 at 2:57
2  
Add your solution as an answer, with working code, and mark the question as answered. Thanks! –  toscho Apr 25 '12 at 5:38
show 3 more comments

1 Answer

up vote 0 down vote accepted

here's what I ended up doing:

<?php 
query_posts(array(
'category__not_in' => array($headline),
'post__not_in' => $postnotin,
'paged' => $paged,
'posts_per_page' => 5
));
if ( have_posts() ): $postCount = 0; ?>
<?php while ( have_posts() ) : the_post(); $postCount++;
if ($postCount < 6) {
?>
[all my code]

<?php } #end if ?> 
<?php endwhile;?>
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.