Skip to content

Instantly share code, notes, and snippets.

@wpexplorer
Created August 16, 2024 20:14
Show Gist options
  • Save wpexplorer/670430ca1b44e77d92f25b2a58280223 to your computer and use it in GitHub Desktop.
Save wpexplorer/670430ca1b44e77d92f25b2a58280223 to your computer and use it in GitHub Desktop.
add_filter( 'redirect_canonical', function( $redirect_url ) {
$posts_with_pagination = [ 1, 2, 3, 4 ]; // array of posts that have custom pagination.
if ( is_paged() && in_array( get_the_ID(), $posts_with_pagination ) ) {
return false;
}
return $redirect_url;
} );
@wpexplorer
Copy link
Author

This example shows how to allow standard pagination on singular posts for specific posts. If you want to target a whole post type or other, please modify accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment