WordPress: Page navigation not working – Jocha

Pagenav, pagination, page navigation.. more like pain to fix!
Being able to navigate through a website is the most important factor for a successful site.

I’ve been struggling with pagenav for my custom WordPress theme for a few days and finally found a working solution.
None of the other fixes I could find on the web worked, I still got 404 Page Not Found error.

Here’s the fix I implemented; paste this into your functions.php (or preferably a custom-functions.php!):

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;
}
add_filter('request', 'remove_page_from_query_string');

Share this page if it helped you, and feel free to leave a comment below!