WordPress: Pagination on Custom Post Archives

Custom post types are a great feature that WordPress introduced in version 3.0. We use them on a regular basis for many clients sites and it gives us even more control and flexibility over websites that we create for clients.

Something that doesn’t work as you would expect is the pagination of custom post types on archive pages. A few months back we were banging our heads against the wall trying to get pagination to work. After some searching on the forums, we found the solution.

A neat little function that you add to your website’s functions.php file:

add_filter('redirect_canonical','my_disable_redirect_canonical');
 
function my_disable_redirect_canonical( $redirect_url ) {
    if ( is_singular( 'custom-post-type' ) )
    $redirect_url = false;
    return $redirect_url;
}

Just replace ‘custom-post-type’ with the name of your custom post type.

Free Graphics, Icons, Tutorials
Free Graphics Free Christmas Vector Icon Graphics Pack 2017Free Fitness Vector Icons Graphics PackFree Camping Vector Graphics PackFree Summer Graphics PackFree File Icon PackFree Fast Food Vector Graphics
Sharing is caring...
Like & Follow
Share the love, share this page! Facebook Twitter Google Digg Reddit LinkedIn Pinterest Email
Close [X]
The Web Taylor
1000 Lakeside North Harbour Portsmouth, Hampshire PO6 3EN
02392 123358