Putting this up after having hit a brick wall for possible solutions.
Have a site with quite a few custom post types and associated custom taxonomies. To help make things easy, I’m using a unified taxonomy.php
template.
Within that template there are three loops. I would like all of them to run on the first page, after that, just the third loop. I understand how to make that work with is_paged()
but there’s a bigger problem that I just cannot resolve.
In my $args
I included $paged
from
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
But $paged
always returns as 1, now matter what page I am on. If I do a straight
get_query_var('paged')
Then nothing is returned, no matter if I am on the first, second, third or etc page.
I’ve read that you need to reset each loops for this to work, and that’s a practice I’ve always followed.
I won’t include the whole page here, as this is a rather long and complex taxonomy. Instead I’ll show the base set up of the two loops.
NOTE: I can’t use pre_get_posts
for this page as it affects all loops. Each of these loops have separate posts_per_page
requirements and other aspects that need to be kept separate.
At the top of the template I have
//this present duplication
$do_not_duplicate = array();
global $wp_query;
$term = $wp_query->queried_object;
And I set up my loop after my args with
while ($new_query->have_posts()) : $new_query->the_post();
The third loop that I want paged has this code nearby
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args=array(
'posts_per_page' => $total_posts,
'post__not_in' => array_merge($do_not_duplicate, $unwanted_post_ids ),
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => $term->taxonomy,
'field' => 'slug',
'terms' => $term->slug,
)
)
);
// Re-run the query with the new arguments
query_posts( $args );
I have been using wp_query
rather than query_posts
, but for my latest attempts that’s what I’ve had there. Would prefer to change it back.
Any ideas?