Skip to main content
2 of 5
added 104 characters in body
henrywright
  • 3.1k
  • 6
  • 39
  • 65

You should use the pre_get_posts filter for this. For example, you could do this in your theme's functions.php file:

function limit_category_posts( $query ) {
    if ( $query->is_archive() ) {

        // Do not do this for the date or category archives.
        if ( $query->is_date() || $query->is_category() )
            return $query;
        
        if ( is_category( '8' ) {
            $query->set( 'posts_per_page', 2 );
        }
    }
    return $query;
}
add_filter( 'pre_get_posts', 'limit_category_posts' );
henrywright
  • 3.1k
  • 6
  • 39
  • 65