Posts per Page on Author and Date Archives
Sets how many posts appear on author and date (year, month, day) archives, independent of the main blog setting.
Opens WPIDE on
Code
// Posts per page on author archives and date archives.
$wpide_author_per_page = 20;
$wpide_date_per_page = 30;
add_action( 'pre_get_posts', function ( $query ) use ( $wpide_author_per_page, $wpide_date_per_page ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( $query->is_author() ) {
$query->set( 'posts_per_page', (int) $wpide_author_per_page );
} elseif ( $query->is_date() ) {
$query->set( 'posts_per_page', (int) $wpide_date_per_page );
}
} );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.