Show different posts per page depending on context (e.g., homepage, search, archive)
Many times you need to show different number of post per category page in WordPress. Use below code snippet do that. Read about how to change URL prefix for custom post types in WordPress.
Code For Different Posts Per Page.
Add this code in function.php of your theme
function five_posts_on_homepage( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'posts_per_page', 5 ); } } add_action( 'pre_get_posts', 'five_posts_on_homepage' );