Wordpress query_posts posts_per_page not working
Can't figure out why this is not limiting the posts_per_page. It is displaying a very long list of posts, but I only want to show 4开发者_如何学运维
query_posts('posts_per_page=4&post_type=page&pagename=media');
if(have_posts() ) :
while(have_posts()) : the_post();
Please try wp_reset_query(); before your code.
// Reset Query
wp_reset_query();
query_posts('posts_per_page=4&post_type=page&pagename=media');
if(have_posts() ) :
while(have_posts()) : the_post();
You are resetting the query each time. You need to include the existing query string, otherwise when you paginate the pagination information will be lost.
Try this instead.
global $query_string;
query_posts( $query_string . '&post_type=page&pagename=media' );
Also to note, if you are specifing a specific page with pagename=media then how can than paginate, it should only return one page?!
I had this same problem on a wordpress site and I tried all the ways to find that site was using Posts per category plugin which was overriding the posts_per_page argument.
精彩评论