OK, here's my prob. I have static homepage and a separate posts page on my wordpress site. I have defined the two in the admin panel. Now, I have also set the max number of posts to be displayed to 5(in settings> reading), but all the posts(10+) are still being displayed on the blog page.
I'm also displaying the latest 3 posts on the static homepage using a custom query. i.e
$wp_query = new WP_Query( array( 'posts_per_page' =>3)); <results loop code>
But this list also is displaying more than 3 posts.It seems wordpress is ignoring the posts_per_page limit I set whether I do it at the admin panel or through code. What the hell is going on? This is my 1st time using wordpress for developing a site. Is this a common problem for noobs?
I just stripped the static homepage bare and left a basic code block that simply fetches titles of the posts. More than 3 posts are still being returned. Here is the actual(and only) code currently in the homepage:
<div id="content"> <?php $wp_query = new WP_Query( array( 'posts_per_page' => 3) );?> <?php if ( $wp_query->have_posts() ) : ?> <ul> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <li> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a> </li> <?php endwhile;?> </ul> <?php endif; ?> </div>
$wp_queryfor your custom queries, that's the global var WordPress uses for the main loop, and you may get unpredictable results using it for other purposes.