• Resolved malibur

    (@malibur)


    Hi,

    I have a website running with this plugin on a lot of custom post types without any problems. All the post types have a translated slug so that the url are in the correct language too.

    Then when I click one of the language switchers it correctly directs me to the corresponding post in that language. However, this breaks with custom taxonomies. the link still shows the slug for the current language, rather than the target language, resulting in a 404 page not found.

    This made me look into the other links for custom post type posts, and the html here, displays the wrong permalink as well. So I’m thinking that its actually been wordpress redirecting me to the correct page all along, since wordpress seems able to “guess” urls when they are somewhat close enough – Though not able to do this with taxonomies.

    Am I doing something wrong?

    please let me know how I am suppose to handle correct slug changes for both post types and taxonomy archive pages. I am translating the slug like this:

    'rewrite' => array( 'slug' => _x( 'season', 'URL slug', 'my-domain' ) ),

    ..when registering the taxonomy

    Thanks!

    https://wordpress.org/plugins/multisite-language-switcher/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    Hi,

    thanks for pointing that out. I think this will be one of the most important enhancements for the next releases but for now my explanation and a workaround…

    The redirect-object is global and that’s the reason why a switch to another blog has no impact in these cases. For custom post types you can use a filter in this way:

    function my_msls_options_get_permalink( $url, $language ) {
        if ( 'de_DE' == $language ) {
            $url = str_replace( '/products/', '/produkte/', $url );
        }
        return $url;
    }
    add_filter( 'msls_options_get_permalink', 'my_msls_options_get_permalink', 10, 2 );

    I will look into this for creating a better solution.

    Cheers,
    Dennis.

    Hi,
    sorry for my question. I’m stopped on the first step: I cannot translate my custom post type slug.
    I tried to use a code like this:

    function my_msls_options_get_permalink( $url, $language ) {
        if ( 'de_DE' == $language ) {
            $url = str_replace( '/products/', '/produkte/', $url );
        }
        return $url;
    }
    add_filter( 'msls_options_get_permalink', 'my_msls_options_get_permalink', 10, 2 );

    but it doesn’t work for me. My url does’t change.
    Sure I make something wrong. Can anybody help me please?

    I put the code in function.php in my child theme (I tried also in function.php of the Theme). Is it the right place?
    I created my custom post type with plugin Custom Post Type UI by WebDevStudios.com.

    Thanks !

    Plugin Author Dennis Ploetner

    (@realloc)

    Hi,

    this is not for translating slugs. It’s just a workaround to get the Multisite Language Switcher work with translated slugs.

    Cheers,
    Dennis.

    Hi Dennis,
    thanks for your fast reply!!! But I’ve not understood well, perhaps I explained in a wrong way.
    If have:
    “products” my custom post type (English)
    “produkte” my custom post type (Deutsch)
    I cannot connect a “produtcs” with his Deutsch version.
    For this reason I’ve now named my custom post type as “products” in both languages, English and Deutsch, and I tried to use your workaround to show a different url for Deutsch posts.
    I expected to have:
    /en.mysite.com/products/mypost
    /de.mysite.com/produkte/mypost

    Thanks again.

    Thread Starter malibur

    (@malibur)

    Hi Dennis, When do you think this feature will be included in the plugin? Thank you. Not that i need a specific data, just an approximate time like next month, in 6 months or 1 year? not to hold you up on anything.

    Plugin Author Dennis Ploetner

    (@realloc)

    The workaround fixes this but I’m working already on a better solution that should be available soon (I think in the next 3 weeks).

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Translating taxonomy slugs’ is closed to new replies.