• Hello, I would like to know how can i can have 2 pages with the same name but different languages and different permalinks.

    I’d like to have this:

    http//mywebsite.com/en/contact > contact page in English
    http//mywebsite.com/fr/contact > contact page in French

    but it is actually doing this:

    http//mywebsite.com/en/contact
    http//mywebsite.com/fr/contact-2

    I certainly miss something in configuration but what ?

    Thanks for your help

    https://www.ads-software.com/plugins/polylang/

Viewing 15 replies - 1 through 15 (of 30 total)
  • Thread Starter remiblaza

    (@remiblaza)

    Herebelow my Polylang settings:

    I use a static frontpage

    The language is set from the directory name in pretty permalinks
    Example: https://myswebsite.com/en/my-post/

    Remove /language/ in pretty permalinks
    Example: https://myswebsite.com/en/

    Detect browser language : When the front page is visited, set the language according to the browser preference
    Media : Activate languages and translations for media

    Hi,

    Did you manage to find the answer to your question? I am looking for the answer of the same question as well.

    Please let me know if you managed to implement the desired behaviour.

    Regards,
    Ally

    As I understand from this thread, this behaviour could not be achieved.

    https://www.ads-software.com/support/topic/why-is-the-same-slug-between-the-languages-not-allowed?replies=5

    Which seems very strange to me…

    It’s related to wordpress architecture, not polylang.

    WordPress uses ‘slug’ to identify content/build the permalink. That slug is automatically made out of the title as it has mostly chance to reflect the content of the webpage displayed, you can edit it by hand too. Although a test is made when you’re submitting a hand made slug to check its uniqueness.

    – page slug have to be unique at their hierarchical tree level(same slug at different level of parenting should be ok)
    – post slug have to be unique along other post (one page and one post can have same slug)
    – attachement have to be unique along all other types

    Don’t know if wp team corrected the behaviour but if you trash a post without completely erasing it, its slug remain blocked for new post, although may be it’s not true anymore in last version (it would be more logic to truncate trashed post’s slug and use it on demand for new one.)

    It’s all about how wordpress build URL. And how an URL build the page : permalinks have to be unique, and rather ‘have’ to remain the same along time and being human readable.

    That’s why polylang can add a /lang/ in the URL, but the core of wordpress doesn’t rely on it :
    www.***.com/en/contact or www.***.com/fr/contact have the same slug, so despite the cosmetic difference polylang inject, both page are www.***.com/contact for wordpress, what to do with that omg !panic!

    … sometimes I feel like wordpress is avoiding slug clone like it could create a black hole and end the universe & Murakami should write about ??

    Oh, thank you for your reply. But I feel so desperate.

    My website is implemented in 4 languages. I really can’t stand all the translated URLs (the value is taken from the page title). What approach could you recommend for avoiding URL translation? If the titles were in Latin letters, I would reconcile. However two of the languages use Cyrillic letter and it is soooo ugly ??

    I do not like indexing the ULSs as well:
    https://www.yourwebsite/product
    https://www.yourwebsite/product-2

    Any advice would be much appreciated.
    Regards

    I’m trying to get this working for almost a week. Tried Polylang, WPML (which actually allows having same permalinks for posts and pages, but not taxonomies, categories etc), tried hooking into template loading and template redirects, changing permalink structures etc. No results. I even explained it in details in front of Andrew Nacin and other core developers in Core blog. It is just a way WordPress works right now. It heavily relies on slugs in permalinks, that’s why they must be unique.

    So, the answer right now is “it’s impossible”. But I’m still looking for a solution, workaround or a hack to overcome these limitations. The solution must be stable and reliable as I’m building large platform. When I’ll find this solution, I’ll post it here.

    Thread Starter remiblaza

    (@remiblaza)

    Hello,

    Indeed, after all it seems there is no way to get this behaviour with Polylang.
    The way that wordpress and polylang currently working not allowing multiple slug.
    I tried the php code suggest by AndyDeGroo in this post:
    https://www.ads-software.com/support/topic/plugin-polylang-identical-page-names-in-different-languages?replies=8
    but it seems it is not working anymore.
    Finally there is no solution available unless switch to an other plugin such as WPML or create a WordPress multisite.

    anonymized-13603639

    (@anonymized-13603639)

    I had the same issue and my solution is to set the slug to local language. For example

    http//mywebsite.com/en/contact > contact page in English
    http//mywebsite.com/fr/contactez > contact page in French
    http//mywebsite.com/de/kontakt > contact page in German
    http//mywebsite.com/es/contacto > contact page in Spanish

    This makes more sense, I think.

    A little problem will be if you have a slug which is the same in differnet languages. So you have to be a little bit creative ?? Like

    http//mywebsite.com/en/car-bmx-x5 > page in English
    http//mywebsite.com/fr/voiture-bmx-x5 > page in French
    http//mywebsite.com/de/auto-bmx-x5 > page in German
    http//mywebsite.com/es/coche-bmx-x5 > page in Spanish

    This works for me.

    Hi guys!

    also need to fix something like that.

    someone used in this case some kind of redirects?

    p.s subscribing.

    Just to keep all the subscribers informed – there’s no way to do it with Polylang and it’s actually WordPress limitation, not the plugin.

    Core team is working on terms and taxonomies, the way they act will be changed. But there’s no specific deadline for this, it’s under consideration for 4.2 but no promises yet.

    For my project I decided to create my own multilingual solution, and after many hours it works. But it’s too specific for our project, uses custom db tables and custom classes instead of core ones, so it can’t be distributed as a plugin.

    Ulrich

    (@grapplerulrich)

    I have created a plugin that should help with this. You can download it here.

    https://github.com/grappler/polylang-slug

    FYI: This does not solve the problem with post and page slugs conflict when permalink setting is set to /%postname%/. https://core.trac.www.ads-software.com/ticket/13459

    Ping @andydegroo & @galpeaceman

    Plugin Author Chouby

    (@chouby)

    Hi!

    @ulrich, thanks for sharing.

    @ihor, yes there is a WordPress limitation for taxonomy terms. The first step has been done in WP 4.1, see #22023. Now I am waiting for the second step #20783.

    Ulrich

    (@grapplerulrich)

    @chouby – I am having trouble with the URL not working. I have created two pages with the name “Blog” one in en and the other in de: /en/blog/ and /de/blog/. The problem is that when I call _get_page_link() on using the id for the de page I get /en/blog/ instead of /de/blog/.

    I was testing it with this code and and I was getting _get_page_link() return /en/blog/ and $polylang->links_model->add_language_to_link($link, $polylang->model->get_post_language( $post->ID) ) return /de/blog/. I am not sure why it is doing so.

    function my_admin_notice(){
    	global $wp_rewrite, $post, $polylang;
    	$post = get_post( $post );
    	$draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
    	$link = $wp_rewrite->get_page_permastruct();
    	if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) {
    		if ( ! $leavename ) {
    			$link = str_replace('%pagename%', get_page_uri( $post ), $link);
    		}
    		$link = home_url($link);
    		$link = user_trailingslashit($link, 'page');
    	} else {
    		$link = home_url( '?page_id=' . $post->ID );
    	}
    	echo '<div class="updated"><p>' . _get_page_link() . '</p><p>' . $polylang->links_model->add_language_to_link($link, $polylang->model->get_post_language( $post->ID) ) . '</p></div>';
    }
    add_action('admin_notices', 'my_admin_notice');

    Plugin Author Chouby

    (@chouby)

    Hi Ulrich,

    Polylang evaluates each link only once. The function hooked to _get_page_link starts by:

    if (isset($this->_links[$link]))
    	return $this->_links[$link];

    So you always get the first. Here the English one.

    Ulrich

    (@grapplerulrich)

    Hi Chouby,

    I got it to work by changing it to:

    if ( isset( $this->_links[$link] ) && ! empty( $this->links_model->get_language_from_url( $link ) ) )
    	return $this->_links[$link];

    Now I need to work out why the /de/blog/ page is redirecting to /en/blog/.

    Happy New Year!

Viewing 15 replies - 1 through 15 (of 30 total)
  • The topic ‘Create 2 pages with same name but different languages and permalinks’ is closed to new replies.