FriendlyWP
11/22/2013 - 6:37 PM

Fixes page navigation giving 404 errors on page/2 and beyond when using custom permalinks like category/postname.

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;
}