Wordpress - WordPress /page/2 404 pagination problem - what to do?

I had the same problem and I noticed that in the 'posts_per_page = 6' and 'Settings/Reading on 'options-reading' WordPress argument, I was set to 10. When I put everything to the same value (6 in my case) everything started working again.


Tried several hours, until I found a working solution in this article.

In your functions.php file, add

/**
 * Fix pagination on archive pages
 * After adding a rewrite rule, go to Settings > Permalinks and click Save to flush the rules cache
 */
function my_pagination_rewrite() {
    add_rewrite_rule('blog/page/?([0-9]{1,})/?$', 'index.php?category_name=blog&paged=$matches[1]', 'top');
}
add_action('init', 'my_pagination_rewrite');

Replace blog with your category name in the code above.

After adding this code, make sure you go to Settings > Permalinks and click Save to flush the rules cache, or else the rule will not be applied.

Hope this helps!


In my case with custom links: /%category%/%postname%/ I had a problem with: /news/page/2/

And finally this works for me (add to functions.php):

function remove_page_from_query_string($query_string)
{ 
    if ($query_string['name'] == 'page' && isset($query_string['page'])) {
        unset($query_string['name']);
        $query_string['paged'] = $query_string['page'];
    }      
    return $query_string;
}
add_filter('request', 'remove_page_from_query_string');