How to Change the Number of Posts on Category Pages in WordPress

In WordPress, there is a setting to change the number of posts listed on blog pages (on the non-static homepage, category pages, tag pages, other archive pages and search results pages). It is called "Blog pages show at most" and located at "WordPress Dashboard" -> "Settings" -> "Reading".

But what if you want to display a different number of posts on category pages than on other blog pages? Let's say you want to display 20 posts on category pages. You can achieve this by adding the below PHP code to the functions.php file of your theme:

function themesdna_number_of_posts_on_category_pages( $query ) {
    if( $query->is_main_query() && ! is_admin() && ( $query->is_category() ) ) {
        $query->set( 'posts_per_page', '20' );
    }
}
add_action( 'pre_get_posts', 'themesdna_number_of_posts_on_category_pages' );

Note: Replace the value "20" with the number of posts you want to display on category pages.

Our WordPress Themes

Below are some of our premium WordPress themes. View all our free and premium WordPress themes →
EasyWP PRO WordPress Theme

EasyWP PRO

If you like EasyWP free WordPress Theme, you will love the premium version. EasyWP PRO is an user friendly, HTML5/CSS3...

$25.00
GridFeel PRO WordPress Theme

GridFeel PRO

$25.00
WriteMag PRO WordPress Theme

WriteMag PRO

WriteMag PRO is improved and feature-rich version of WriteMag Free WordPress Theme. When compare with the WriteMag free version, PRO...

$25.00
HotWP PRO WordPress Theme

HotWP PRO

If you like HotWP free WordPress Theme, you will love the HotWP premium version. HotWP PRO is easy to use,...

$25.00
GridShow PRO WordPress Theme

GridShow PRO

GridShow PRO WordPress theme is a feature-rich, advanced version of GridShow Free WordPress Theme. GridShow PRO version has color and...

$25.00
GridMe PRO WordPress Theme

GridMe PRO

If you have tried GridMe Free WordPress Theme, then you will love the premium version. It will help you to...

$25.00
GridSoul PRO WordPress Theme

GridSoul PRO

$25.00
GridLane PRO WordPress Theme

GridLane PRO

If you like the free version of GridLane WordPress Theme, you'll love the premium version even more. It will help...

$25.00

Can't you choose a single theme? Purchase All Themes for $75.

Save money with our low, one-time price for access to all of our 56 WordPress themes.