I am working with category.php. I have my posts returning how I want them, I am getting the child categories how I want them but now I am trying to add pagination and limit the amount of posts to 3. When I ran my test, the 4th post showed up on the page. I was expecting only 3 and the pagination at the bottom. I am not sure what is wrong. According to the codex, this should be working.
$allcats = get_categories('child_of='.get_query_var('cat'));
foreach ($allcats as $cat) :
$args = array(
'category__in' => array($cat->term_id)
);
$customInCatQuery = new WP_Query($args);
if ($customInCatQuery->have_posts()) :
echo '<div class="menupageContent">';
$terms = apply_filters( 'taxonomy-images-get-terms', '' );
if ( ! empty( $terms ) ) {
foreach( (array) $terms as $term ) {
if($term->term_id == $cat->term_id) {
echo wp_get_attachment_image( $term->image_id, 'menu' );
}
}
}
echo '<h3>'.$cat->name.'</h3>';
echo '<ul>';
while ($customInCatQuery->have_posts()) : $customInCatQuery->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
echo '</ul></div><!--end menupageContent-->';
?>
<?php else :
echo 'No post published in:'.$cat->name;
endif;
wp_reset_query();
endforeach;
?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'paradiso' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'paradiso' ) ); ?></div>
<?php endif; ?>