Skip to content

Instantly share code, notes, and snippets.

@FriendlyWP
Created November 22, 2013 18:37
Show Gist options
  • Save FriendlyWP/7604763 to your computer and use it in GitHub Desktop.
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.
// 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