Reputation: 53
I have customized the archive page for a client, and have edited the query that it makes to exclude a category and limit the page to 8 posts. I've also added a sidebar which uses the Archive widget. Whenever I click on an Archive link it will show all of the posts not the posts for that Month. The same thing happens with the tags, it will return all the posts and not just the posts with that tag.
<div class="row site-module-inner">
<?php $args = array( 'posts_per_page' => 8,
'category__not_in' => get_category_by_slug('news')->term_id,); ?>); ?>
<?php $query = new WP_Query($args); ?>
<?php $count = $query->post_count;
$counter = $query->post_count;
if ($count % 2 == 0) {
$last = true;
} else {
$last = false;
}
?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="item <?php if ((!($last) && $counter == 1) || ($last && $counter <= 2)) { echo " bottom"; } ?> ">
<?php get_template_part( 'template-parts/post', 'listing' ); ?>
</div> <!-- item -->
<?php $counter--; ?>
<?php endwhile; wp_reset_query();?>
</div> <!-- row -->
What I've provided is the query loop for the archive page, on the page there are no other query loops except for a pagination loop, but it doesn't affect the main loop, I have tested for that. Any suggestions or insight is appreciated
Upvotes: 0
Views: 48
Reputation: 53
I have found the solution to my own problem, a custom query completely overrides any arguments from the original query. Which is why it won't work.
Upvotes: 0