I'm using two loops on homepage, one is to show the 3 latest posts, and the other one to show the rest of the posts minus the 3 first posts.
I'm using the following code for the pre_get_posts.
function tax_and_offset_homepage( $query ) {
if ( !is_admin() && $query->is_home() && $query->is_main_query() )
$query->set( 'post_type', array( 'post') );
$ppp = get_option( 'posts_per_page' );
//$ppp = 300;
$offset = 3;
if ( !$query->is_paged() ) {
$query->set( 'posts_per_page', $ppp);
$query->set( 'offset', $offset);
}
}
add_action('pre_get_posts','tax_and_offset_homepage');
and the following code for the basic loop:
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
//
} // end while
} // end if
?>
but the problem is that the pre_get_posts can be applied to one of the 2 loops. How can i have 2 pre_get_posts function for two loops on same page?
pre_get_posts
? It's better to use that filter on the main query, or all queries, it doesn't make as much sense to modify custom loops with it. It's better to pass the arguments through a custom filter in that scenario