WP SITES

3086 Coded Tutorials & 291 Plugins

Set Posts Per Page Limit For Each Author Archive Page

Generally, the number of posts displayed on your archives pages is determined by your reading settings.

Reading Settings

If you want to control the number of posts displayed on a specific archive page like your author archives, you can.

Use the pre_get_posts function in your functions.php file like this:

function set_author_archive_limit( $query ) {
    if ( is_admin() || ! $query->is_main_query() )
        return;

    if ( is_author() ) {
        
        $query->set( 'posts_per_page', 10 );
        return;
    }
}
add_action( 'pre_get_posts', 'set_author_archive_limit', 1 );

Simply change the 10 in the code to any number you like.

Leave a Reply

New Plugins