I have a number of Custom Content Elements setup for the blog loop, first post, post navigation, categories, search results, etc.
When I add the code below to change the number of posts on the first page, all elements except for the blog loop and first post which has the blog loop as a parent stop working.
add_action( 'pre_get_posts', 'tu_change_posts_per_page', 1 );
function tu_change_posts_per_page( &$query ) {
if ( ! is_main_query() ) {
return;
}
if ( ! $query->is_paged ) {
$query->set( 'posts_per_page', 10 );
}
}