I have a custom taxonomy (support) and a custom post type (question) both related.
In my taxonomy-support.php template file, I use the following query:
<?php
$current_category = get_term_by('id', get_queried_object()->term_id, 'support');
$questions = new WP_Query(array(
'post_type' => array('question'),
'post_status' => 'publish',
'posts_per_page' => 2,
'paged' => ((get_query_var('paged')) ? get_query_var('paged') : 1),
'nopaging' => false,
'tax_query' => array(
array(
'taxonomy' => 'support',
'terms' => array($current_category->term_id)
)
),
'orderby' => 'menu_order',
'order' => 'ASC'
));
?>
And the loop
<?php if ($questions->have_posts()): ?>
<ul>
<?php while ($questions->have_posts()) : $questions->the_post(); ?>
<li>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
</li>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
</ul>
<div class="clearfix">
<div class="pull-left">
<?php previous_posts_link('← ' . __('Previous', 'my-theme' ), $questions->max_num_pages); ?>
</div>
<div class="pull-right">
<?php next_posts_link(__('Next', 'my-theme') . ' →', $questions->max_num_pages); ?>
</div>
</div>
<?php endif; ?>
As you can see I defined 2 posts per page.
When I visit the page, it shows me 2 posts then I go to page 2, it still works but when I go to page 3 or up, it shows 404.
Any idea?
I'm using WordPress 3.8.2 with no plugin installed.
Thanks