Last active
February 16, 2022 20:34
-
-
Save khleomix/5d2215abdb4338011ba3aa645a99c5d0 to your computer and use it in GitHub Desktop.
Fix for error 404 on last page If using custom pagination for custom post type and with different posts_per_page value from settings. Add to functions.php/queries.php
This file contains 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 | |
/** | |
* Fix pagination on archive pages | |
* | |
* @author JC Palmes | |
*/ | |
function khleomix_remove_page_from_query_string( $query_string ) { | |
if ( isset( $query_string['name'] ) == 'page' && isset( $query_string['page'] ) ) { | |
unset( $query_string['name'] ); | |
$query_string['paged'] = $query_string['page']; | |
} | |
return $query_string; | |
} | |
add_filter( 'request', 'khleomix_remove_page_from_query_string' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment