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 0.9.5.4 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.
-
Hello Gonçalo Peres,
Yes, 0.9.5.4 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: http://wordpress.org/support/topic/same-post-in-different-urls
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 (0.9.5.5)
http://downloads.wordpress.org/plugin/polylang.zipHello Chouby.
The problem with “/category/name/page/1” is still present on Polylang 0.9.5.5
Test case:
http://www.voiceoverportugal.com/pt/cat/video
http://www.voiceoverportugal.com/pt/cat/video/page/1The second URL is not redirect to first one.
WordPress Multisite 3.4.2 / Polylang 0.9.5.5Thank you and keep it up 🙂
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:
http://codex.wordpress.org/Function_Reference/paginate_linksThis 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: http://www.hipersuper.pt/category/producao/page/1/
This site doesn’t have Polylang and so the redirection takes place.Thank you for looking into it.
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 0.9.5.5
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 🙂
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.
Test: http://saraperes.com/pt/blog/trabalhos-recentes/page/1Permalink 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: http://saraperes.com/en/
– [unchecked] Hide URL language information for default language
– [checked] When using static front page, redirect the language page (example: http://saraperes.com/en/) 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!
I reproduced the bug with your settings. Hopefully, this time I fixed it in the development version 0.9.6.3.
http://downloads.wordpress.org/plugin/polylang.zipThe 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.
The topic ‘Archive navigation problem’ is closed to new replies.