Replies: 0
Hi!
I have multiple queries in the same page, like this:
$args_1 = array (
'category_name' => get_query_var( 'category_name' ),
'post__in' => $sticky = get_option( 'sticky_posts' );
'orderby' => 'date',
'order' => 'DESC'
);
$sticky_query = new WP_Query ($args_1);
// loop
$args_2 = array(
'category_name' => get_query_var( 'category_name' ),
'post__not_in' => get_option( 'sticky_posts' ),
'category__not_in' => array(11114),
'orderby' => 'date',
'order' => 'DESC'
);
$query_2 = new WP_Query ($args_2);
// loop
$args_3 = array(
'category_name' => get_query_var( 'category_name' ),
'post__not_in' => get_option( 'sticky_posts' ),
'category__in' => array(11114),
'orderby' => 'date',
'order' => 'DESC'
);
$query_3 = new WP_Query($args_3 );
// loop
I would:
1) limit the total of posts per page to 15
2) (I can’t do this, I’ve searched anywhere but I didn’t find a solution) Make this “combined” pagination works . Now, and it’s logical, the second page is the same as the first page…
Or the solution can be to make only one query and group the posts and order the groups instead? I’ve tried with something like:
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
if ( 'post' === get_post_type() ) { // Only display posts from post post type
// Do what you need to do post post type posts
}
}
rewind_posts(); // Rewind the loop so we can run it again
while ( have_posts() ) {
the_post();
if ( 'page' === get_post_type() ) { // Only display posts from page post type
// Do what you need to do page post type posts
}
}
}
but the pagination doesn’t work: in fact, it calculates the limit of 15 posts per page for each of two loops.
How can be so difficult in WordPress make working the pagination for a common pattern like this?
Thanks in advance!
Thanks