WordPress – customize posts per page for tag, category and date archive pages

The following code can be used to have separate value of posts per page for various archive pages (category, tag, date, author, etc.)

add_filter('pre_option_posts_per_page', 'posts_per_page_filter');
function posts_per_page_filter() {
  if ( is_archive() ) {
    // date,tag
    if (is_date() || is_tag() ) {
      return 30;
    }
    if (is_category() ) {
      return 20;
    }
  }
  return 10; // default
}

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments