Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
314 B
3
Indexable
Never
add_action( 'pre_get_posts', function( \WP_Query $query ) {
	if ( is_admin() || ! $query->is_main_query() ) {
		return;
	}

	switch ( $query->get( 'post_type' ) ) {
		case 'blog':
			$query->set( 'posts_per_page', 10 );
			break;
		case 'news':
			$query->set( 'posts_per_page', 5 );
			break;
	}
} );