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.

On the first page of a specific category, I want WordPress to show 4 posts per page. On the following pages, however, I'd like to have 6 posts per page. I tried using a conditional query (see below), but this completely screwed up the number of posts per page...

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                 
if ($paged == 1) {                              
    query_posts("posts_per_page=4&category_name=Neuigkeiten&paged=$paged");
}
elseif ($paged > 1) {
    query_posts("posts_per_page=6&category_name=Neuigkeiten&paged=$paged");
}

This leads to 3 posts being displayed in a wrong order. There's probably a stupid mistake in there, but I can't figure it out. Echoing the $paged variable works just fine.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

One way to do it is use WordPress › Custom Post Limits « WordPress Plugins. That plugin gives options for individual categories, first page and pages, archives and search results without needing custom loops in template files.

share|improve this answer
    
Thanks, this looks like it could solve my problem. However, I'd prefer a way to do this without a plugin... –  Daniel Jul 10 '12 at 12:54
    
oh what the hell, the plugin works like a charm. Thanks! :) –  Daniel Jul 10 '12 at 17:40
    
It does work well; it might be mu-plugins aware so that end users don't disable it, if that's a concern: codex.wordpress.org/Must_Use_Plugins –  songdogtech Jul 10 '12 at 17:43

Refer this link:

http://wpdevelopertips.com/different-number-of-posts-in-pagination-pages/

It will show the code to show different number of posts in the second pagination pages onwards.

share|improve this answer
    
An answer should be more than just a link to an external site. Please add a solution. –  toscho Nov 3 '12 at 14:09

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.