I have a custom rewrite rule for “catalog” pages on my website to display the items within the specified catalog. Everything works great except the pagination which mysteriously returns a 404 error page if the user tries to navigate to a page greater than page 9. Below is the entire rewrite code. Other archives on the website have no issue with pages past page 9 so I feel like this must have something to do with the regex in my rewrite rule, but I’m lost as to what it could be.

function x_rewrite_rule_form_submissions()
{
    add_rewrite_tag('%catalog%', '([^&]+)');
    add_rewrite_rule('catalog/([^/]+)/page/([0-9]+)/?', 'index.php?catalog=$matches[1]&paged=$matches[2]', 'top' );
    add_rewrite_rule('catalog/([^/]+)/?', 'index.php?catalog=$matches[1]', 'top');
}
add_action('init', 'x_rewrite_rule_form_submissions', 10, 0);

Read more here: WordPress Custom Rewrite Rule Returns 404 When Current Page Past 9


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: