Access our premium support and let us know your problems, we will help you solve them.

0
No products in the cart.

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: pagination on custom post wp_query #9515
    blankoctavialo
    Participant

    This question was answered very adequately by @Trevor but I needed to implement numbered pagination, and there was a bit more research to do. I hope my code helps others implement numbered pagination.

        <div class="frontpage-posts">
            <?php
            if (get_query_var('paged')) {
              $paged = get_query_var('paged');
            } elseif (get_query_var('page')) {
              $paged = get_query_var('page');
            } else {
              $paged = 1;
            }
            $temp = $wp_query;
            $wp_query = null;
            $wp_query = new WP_Query('posts_per_page=12&paged=' . $paged);
            if ($wp_query->have_posts()) :
              while ($wp_query->have_posts()) : $wp_query->the_post();
                echo the_title();
              endwhile; ?>
              <nav>
                <?php
                the_posts_pagination(array(
                  'mid_size'  => 2,
                  'prev_text' => __('Back', 'textdomain'),
                  'next_text' => __('Onward', 'textdomain'),
                ));
                ?>
              </nav>
            <?php
              $wp_query = null;
              $wp_query = $temp;
              wp_reset_postdata();
            endif;
            ?>
          </div>
    
Viewing 1 post (of 1 total)