Created
May 30, 2018 09:10
-
-
Save asha23/55ecabadbe9923c169bfb7f0cbecd769 to your computer and use it in GitHub Desktop.
Fix pagination on custom post type archive page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//============================================================================== | |
// SORT OUT PAGINATION ON ARCHIVE | |
// This fixes the canonical link on custom post type archive pages | |
// Odd WordPress bug that only occurs on archives | |
//============================================================================== | |
add_filter('redirect_canonical', 'custom_disable_redirect_canonical'); | |
function custom_disable_redirect_canonical($redirect_url) | |
{ | |
global $post; | |
$ptype = get_post_type($post); | |
if ($ptype == '***your post type slug***' && is_archive()) { | |
$redirect_url = false; | |
} | |
return $redirect_url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment