Wp Set Posts Per Page Archive

//cpt == your own custom post type

function set_posts_per_page_cpt( $query ) {
 if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'cpt' ) ) {
 $query->set( 'posts_per_page', '10' );
 }
}
add_action( 'pre_get_posts', 'set_posts_per_page_cpt' );

Leave a Comment