I'm trying to get 5 posts of one category and paginate them, but my loop doesn't get some posts. In this case, I put 5 posts to retrieve but the loop only returns 2 and sometimes 3.
Finally, when I'm trying to use pagination it doesn't work.
Here is my code:
<?php
// Protect against arbitrary paged values
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$args = array(
'category__in' => array( 11 ),
'category__not_in' => '',
'posts_per_page' => 5,
'post_type' => 'post',
'post_status'=>'publish',
'paged' => $paged,
);
$the_query = new WP_Query($args);
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post();
$the_query->the_post();
// Post content goes here...
//
echo '
<h3 class="tituliNota">
<a href="'.get_permalink().'" class="noteTitle">
<b>'.the_title( ' ', ' ', false ).'</b></a></h3>';
get_the_category();
wp_reset_postdata();
endwhile; ?>
<div class="pagination">
<?php
echo paginate_links( array(
'format' => 'page/%#%',
'current' => $paged,
'total' => $the_query->max_num_pages,
'mid_size' => 5,
'prev_text' => __('« Prev Page'),
'next_text' => __('Next Page »')
) );
?>
</div>