0

I'm paginating a custom post type on a custom page. The content of the page is determined by a custom query, like this:

mysite.com/my-account/?sect=orders

When I change sect= to something else the page changes accordingly.

Now on the orders page I wanted to add pagination, and I added it with this code:

echo paginate_links( array(
            'base'               => get_pagenum_link(1) . '%_%',
            'format'             => '&paged=%#%',
            'total'              => $total_pages,
            'current'            => $page_number,
            'show_all'           => false,
            'end_size'           => 1,
            'mid_size'           => 2,
            'prev_next'          => true,
            'prev_text'          => __( '« Previous' ),
            'next_text'          => __( 'Next »' ),
            'type'               => 'plain',
            'add_args'           => false,
            'add_fragment'       => '',
            'before_page_number' => '',
            'after_page_number'  => ''
        ) );

What I want to achieve is that paged=PAGENUMBER is added as a query parameter, so mysite.com/my-account/?sect=orders&paged=PAGENUMBER.

Everything works and the generated pagination links are pointing to the url structure I want, but then when the link is clicked I get a 301 redirect to mysite.com/my-account/page/2/?sect=orders. The pagination works, I get the second page... but that url is very ugly.

How I can change the pagination URL structure only on this my-account page? I want to be a normal &paged=2 query parameter along other parameters.

  • "but that url is very ugly" - actually, mysite.com/my-account/?sect=orders&paged=PAGENUMBER is even uglier.. and doesn't look good for SEO. And one would normally rewrite that to mysite.com/my-account/sect/orders/page/2 and not rewrite the /page/2 to &paged=2.. – Sally CJ Feb 28 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.