Created
July 14, 2021 14:15
-
-
Save jorpdesigns/d96a6061d8a54b4851d56e5bfcccd646 to your computer and use it in GitHub Desktop.
Snippet to set pagination rewrite rule for custom post type
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
<?php | |
add_action('init', 'custom_post_type_pagination_rewrite'); | |
function custom_post_type_pagination_rewrite() { | |
$archiveSlug = 'archive-slug'; // Replace with the archive page slug | |
$archiveID = 55; // Replace with the archive page ID | |
add_rewrite_rule( $archiveSlug . '/page/?([0-9]{1,})/?$', 'index.php?page_id=' . $archiveID . '&paged=$matches[1]', 'top'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment