Skip to content

Instantly share code, notes, and snippets.

@asha23
Created May 30, 2018 09:10
Show Gist options
  • Save asha23/55ecabadbe9923c169bfb7f0cbecd769 to your computer and use it in GitHub Desktop.
Save asha23/55ecabadbe9923c169bfb7f0cbecd769 to your computer and use it in GitHub Desktop.
Fix pagination on custom post type archive page
//==============================================================================
// 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