I created a single page template. Under the content, I use WP_Query to display some related posts.

Can this query be paged ?
I can’t see the pagination anywhere.

Arguements:

                if ( get_query_var('paged') ) {
                 $paged = get_query_var('paged');
                 } elseif ( get_query_var('page') ) {
                 $paged = get_query_var('page');
                 } else {
                 $paged = 1;
                 }
                 $display_count = 36;
                 $offset = ( $paged - 1 ) * $display_count;
              $args=array(
                 'post_type' => 'gadget',
                 'post_status' => 'publish',
                 'tax_query' => array(
                    array(
                        'taxonomy' => 'gadget_categories',
                        'field' => 'id',
                        'terms' => $term_ids,
                        'operator'=> 'IN' //Or 'AND' or 'NOT IN'
                     )),
                 'post__not_in'=>array($post->ID),
                 'posts_per_page' => 36,
                 'paged' => $paged,
                 'nopaging' => false,
                 'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...)
                 'update_post_meta_cache' => false // grabs post meta, remove if post meta required
                );

Pagination:

                        <div class="pagination">
                        <div class="previous"><?php previous_posts_link( 'Older Posts' ); ?></div>
                        <div class="next"><?php next_posts_link( 'Newer Posts', $fp_query->max_num_pages ); ?></div>
                    </div>

Read more here: Paged wp_query under content page


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: