1

Currently I’m having URL for pagination pages as:

http://www.example.com/category_name/page/2

But I need to change this URL structure as:

http://www.example.com/category_name/?page=2

etc.

any solution?

2 Answers 2

1

You may use the format argument of wp_link_pages function like this:

<?php $args = array(
  'base'               => '%_%',
  'format'             => '?page=%#%',
  'total'              => 1,
  'current'            => 0,
  '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'  => ''
); ?>

Its works good for me

See more https://codex.wordpress.org/Function_Reference/paginate_links

0

I managed to achieve this by disabling canonical redirection for pagination queryies like so...

add_filter( 'redirect_canonical', function ( $redirect_url ) {

if ( is_paged() ) {
    return false;
}

return $redirect_url;

}, 10, 1 );

This should get you...

http://www.example.com/category_name/?paged=2

Note, this used paged instead of page as this is reserved for multi-part posts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.