I’ve got a custom loop on a page template with pagination, which was working fine before installing WPML and setting up my languages for the site.

The issue I now have is that the pagination links to /videos/page/2/ which redirect back to /videos/, however if you was to go to /videos/2/ it would show the correct page.

I am trying to write a rewrite rule so that when you click on the navigation links /videos/page/2/ it would show /videos/2/ but keeping the URL as /videos/page/2/

function rewrite_basic() {
    add_rewrite_rule('^videos/page/([0-9]+)/?$', 'index.php?&paged=$matches[1]', 'top');
}
add_action('init', 'rewrite_basic');

Again, I need this to work with the other languages on the site which include the language code within the url, so URL would be /us/videos/

Read more here: WordPress Broken Pagination with WPML – Rewrite Rule Not Working


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: