WordPress paginate_links – first page always the same as current page

I have a custom loop in wordpress and have added pagination to it. I have permalinks set to pretty (eg /custom/).

I have the custom loop set up so it can work despite not being the primary loop. Currently the loop works perfectly by appending ?paged1=[number] and taking the loop to the corresponding page.

Read More

However the first page number in the pagination is always set to be the same as the current page. Eg the href=

  • 1 = ?paged1=3
  • 2 = ?paged1=2
  • 3 = current
  • 4 = ?paged1=4

The same issue as outlined here: https://wordpress.stackexchange.com/questions/87433/strange-paginate-links-behavior-first-page-link-is-always-whatever-page-im-on

However I have pretty permalinks enabled. I tried taking the good advbice in that long anser but didn’t have any luck. This means I want the pagination to work like this

domain.com/page-name?paged1=[number]

and not

domain.com/page-name/page/2

Any advice appreciated. Here is my code

(Code largely used from http://pressedweb.com/wordpress/wordpress-multiple-wp_query-custom-loop-paginations/)

                $paged1 = isset( $_GET['paged1'] ) ? (int) $_GET['paged1'] : 1;
                $args1 = array(
                    'paged'          => $paged1,
                    'posts_per_page' => 18,
                    'post_type' => 'post',
                    'orderby'=>'date',
                    'order'=>'DESC'
                );
                $query1 = new WP_Query( $args1 );

                while ( $query1->have_posts() ) : $query1->the_post();


                    blogside_loop_output();


                endwhile;

                $big = 999999999; // need an unlikely integer

                $pag_args1 = array(
                    'format'   => '?paged1=%#%',
                    'current'  => $paged1,
                    'total'    => $query1->max_num_pages
                );

                        echo paginate_links( $pag_args1 );

                    if ( $paginate_links ) {
                        echo '<div class="pagination">';
                        echo paginate_links( $pag_args1 );
                        echo '</div><!--// end .pagination -->';
                    }

Related posts

Leave a Reply

1 comment

  1. The array for paginate_links needed the following base:

    'base' => @add_query_arg('paged1','%#%'),
    

    That fixed it. Here is the full code for clarity:

                $pag_args1 = array(
                    'base' => @add_query_arg('paged1','%#%'),
                    'format'   => '?paged1=%#%',
                    'current'  => $paged1,
                    'total'    => $query1->max_num_pages
                );