0

When rewriting the url like this: .../%postname%/

This is the relevant part of my post type registration arguments:

'rewrite' => array( 'slug' => 'haendler', 'with_front' => false )

My pagination on the custom post type does not work.

The pagination is there but when I click on page two the link http://www.example.com/%postname%/page/2 always changes back to http://www.example.com/%postname%/

If I disable permalinks to the default querystring style pagination is fine.

What can be the reason for the url automatically removing the page/2 value?

Thanks in advance

  • How did you setup rewrite argument when registering your custom post type – Pieter Goosen Feb 12 '14 at 13:39
  • 'rewrite' => array( 'slug' => 'haendler', 'with_front' => false ), THis is the argument from the register_post_type function. :/ – phalancs Feb 12 '14 at 13:54
  • Set it to true and see what happen – Pieter Goosen Feb 12 '14 at 14:03
4

This issue was reported here : https://core.trac.wordpress.org/ticket/15551

It comes from the redirect_canonical() WP function.

Try to disable canonical redirect for your custom post type to get pagination work :

add_filter( 'redirect_canonical','custom_disable_redirect_canonical' ); 
function custom_disable_redirect_canonical( $redirect_url ){
    if ( is_singular('your_custom_post_type') ) $redirect_url = false;
    return $redirect_url;
}

Hope that helps.

  • Wow you are a genius! Thanks for existing!!!! That totally solved it :-D – phalancs Feb 19 '14 at 15:19
  • You're welcome, glad you found it useful. If the answer solved your problem, you can mark as accepted :) – Céline Garel Feb 20 '14 at 22:35

Your Answer

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

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