In my Wordpress installation I'm using the JETPACK plugin and its Infinite scroll feature.
In the blog home page, I'm using the action pre_get_posts and the filter infinite_scroll_query_args to change the Query and pull common posts and a custom post type.
The problem is that with this the page of the infinite scroll breaks and only counts the pagination of the custom post type that I am using, however pulling both post type normally. Where it was for the infinite scroll to be activated 48 times, it only activates 8 times.
I'm using the following codes:
add_action( 'pre_get_posts', 'function_pre_post' );
function function_pre_post( $query ) {
if ( $query->is_main_query() && $query->is_home() ) {
$query->set( 'post_type', array( 'post', 'critica' ) );
}
}
function jetpack_infinite_scroll_query_args( $args ) {
$args['post_type'] = array( 'post', 'critica' );
return $args;
}
add_filter( 'infinite_scroll_query_args', 'jetpack_infinite_scroll_query_args', 100 );