Created
November 22, 2013 18:37
-
-
Save FriendlyWP/7604763 to your computer and use it in GitHub Desktop.
Fixes page navigation giving 404 errors on page/2 and beyond when using custom permalinks like category/postname.
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
// IF USING CUSTOM PERMALINKS LIKE CATEGORY/POSTNAME, PAGE NAVIGATION BREAKS ON PAGE 2. THIS IS THE FIX | |
// from http://barefootdevelopment.blogspot.com/2007/11/fix-for-wordpress-paging-problem.html | |
add_filter('request', 'remove_page_from_query_string'); | |
function remove_page_from_query_string($query_string) { | |
if ($query_string['name'] == 'page' && isset($query_string['page'])) { | |
unset($query_string['name']); | |
// 'page' in the query_string looks like '/2', so split it out | |
list($delim, $page_index) = split('/', $query_string['page']); | |
$query_string['paged'] = $page_index; | |
} | |
return $query_string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment