Support » Plugin: Polylang » Archive navigation problem

  • Greetings Chouby

    Regarding the problem navigating to a URL like “/category/name/page/2” being redirected back to “/category/name/”, I just tried development version and it fixes that problem.

    However “/category/name/page/1” is still NOT redirecting to “/category/name”. And it’s not good to have two different URLs for the same page.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Chouby


    Hello Gonçalo Peres,

    Yes, was a very quick fix for this pagination issue introduced in 0.9.5. In fact, I just removed a function, which was added to solve this issue:

    Now I have reworked it and hopefully I did not introduced a new bug.

    The problem with “/category/name/page/1” is a different one and should be solved in the current development version too (

    Hello Chouby.

    The problem with “/category/name/page/1” is still present on Polylang

    Test case:

    The second URL is not redirect to first one.
    WordPress Multisite 3.4.2 / Polylang

    Thank you and keep it up 🙂

    Plugin Author Chouby


    Are you using a plugin for pagination? I have no more issue with the standard WordPress pagination functions. In your case, the link is generated with ‘/category/name/page/1’ and Polylang does not generate such link. Basically it just adds the language code to an already created link.

    No navigation plugins, just the good old default “paginate_links()” function in my archive.php template:

    This function generates those nice “prev,1,2,3,…next” buttons to navigate archive pages. When you go to “/category/name/page/2”, the link to the first page becomes “/category/name/page/1”. WordPress detects this and automatically redirects to “/category/name” (301 permanent)

    I believe Polylang somehow avoids this redirection. Could it be the case?

    We can avoid the “page/1” url with this simple trick:

    $big = 999999999;
    $nav_pages = paginate_links( array(
        'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
        'format' => '/page/%#%',
        'current' => max( 1, get_query_var('paged') ),
        'total' => $wp_query->max_num_pages,
        'prev_text' => '«',
        'next_text' => '»',
        ) );
    $nav_pages = str_replace('/page/1', '', $nav_pages);
    echo $nav_pages;

    But it will still exist 2 URLs for the same page, which WordPress by default solves.
    Try it:
    This site doesn’t have Polylang and so the redirection takes place.

    Thank you for looking into it.

    Plugin Author Chouby


    I did not know this function. Thanks for this!

    I included your code in Twenty Ten for test purpose. The link is correctly generated (without /page/1) thanks to your str_replace. The link /category/name/page/1 is correctly redirected to /category/name by WordPress.

    Test done with WordPress 3.4.2 and Polylang 0.9.6

    Yes in Polylang 0.9.5, there is a bug which prevents the WordPress canonical redirection to work correctly in some cases. This should be solved since

    Hello Chouby.

    My “str_replace” fix doesn’t make any redirection, it only avoids the “page/1” link to be created. But all those who use these function in “archive.php” or “index.php” templates, will get the “page/1” link, unless they implement this simple workaround.

    Slight improvement 😉

    if(get_query_var('paged') > 1) $nav_pages = str_replace('/page/1', '', $nav_pages);

    By the way, paginate_links() function has no hooks to make it other way…

    Anyway, are you planning on looking how to make “/pt/category/name/page/1” links redirect to “/pt/category/name”, without this workaround?

    It’s not such a big deal, but let me know if you can work on that. Maybe in the process you can find more WordPress automatic redirections that you missed.

    Thank you Chouby 🙂

    Plugin Author Chouby


    Now it should work. At least it does on my test site. If I remove the str_replace, the link is generated with ‘/page/1’ which is correctly redirected by WordPress without any interference from Polylang.

    If it still does not work with Polylang 0.9.6 then I will need more information to try to reproduce the bug: Permalinks settings, Polylang settings and if you are using a static front page or not.

    Still not working with Polylang 0.9.6.

    Permalink structure: “/%year%/%postname%”

    Category base: “blog”

    Yes I’m using a static front page.

    Polylang Settings:
    – [checked] When the front page is visited, set the language according to the browser preference
    – [checked] The language code, for example /en/, is added to all urls when using pretty permalinks.
    – [checked] Remove /language/ in pretty permalinks. Example:
    – [unchecked] Hide URL language information for default language
    – [checked] When using static front page, redirect the language page (example: to the front page in the right language
    – [unchecked] Allow to synchronize categories, tags, featured image and other metas between translations of a post or page (What is this option for, by the way?)

    Hope you can fix it with not too much trouble 🙂

    Thank you!

    Plugin Author Chouby


    I reproduced the bug with your settings. Hopefully, this time I fixed it in the development version

    The synchronization option allows you (for example) to have exactly the same tags (translated) in posts translations. If you add/remove one in a post, it automatically add/remove it in the translations.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Archive navigation problem’ is closed to new replies.