0

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.

0

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.

  • 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 – markratledge Jul 10 '12 at 17:43
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.