Support » Plugin: Multisite Language Switcher » Map post from different post type name

  • Resolved Suika

    (@suikalum)


    Hi!

    I have two sites at the moment – US and UK.

    They have custom post types named “sanitizers” and “sanitisers” respectively and because they have different custom post type names, they can’t be connected to each other.

    Does anyone know a workaround for this? I have two more on the way which are ES and DE sites so this is really a problem.

    Thanks!

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

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

    (@realloc)

    Hi,

    you could use the ‘gettext’-filter – if you use the standard WordPress translation functions for the translation of the slug – in combination with a hook called ‘msls_options_get_permalink’ which comes with the Multisite Language Switcher. Or that filter alone like here and here.

    I tried to use this:

    function my_msls_options_get_permalink( $url, $language ) {
        if ( 'en_GB' == $language ) {
            $url = str_replace( '/sanitizers/', '/sanitisers/', $url );
        }
        return $url;
    }
    add_filter( 'msls_options_get_permalink', 'my_msls_options_get_permalink', 10, 2 );

    But it’s still not showing in the Multisite Language Switcher dropdown on the post. I don’t use any translator. I just cloned my US site to make a UK site and renamed the custom post type (I use CPT UI) to Sanitiser.

    Or should it still be named as “Sanitizers” on the UK site and this code would just replace its values on the permalinks?

    Plugin Author Dennis Ploetner

    (@realloc)

    How did you register the custom post type? It would work if the post type had the same name but a translated slug. Please provide more information.

    Hello!

    I use the plugin CPT UI / Custom Post Type UI to create and rename my custom posts.

    This was confusing at first when you said it should have the same “name” but translated “slug” because in the plugin I mentioned, the general inputs available are called “name/slug” and “labels” but when I checked the advanced setting below, it has an option to set a “Custom Rewrite Slug” which is where the translated slug should go to.

    Additional reference where I got the idea is the parameters for manually registering post types under the rewrite args.

    Not sure if the filters you mentioned are necessary too this way because I’ve removed them but the urls are fine. Will try for the other languages which have more complex translation and I’ll let you know.

    Hope this helps someone too.

    Thanks, Dennis!

    Plugin Author Dennis Ploetner

    (@realloc)

    OK, thanks for sharing this info!

    Just to confirm, I tried this for my other sites (ES and DE) and they work fine without the filters. Just change the Labels and Custom Rewrite Slug on CPT UI and you’re good to go. Take note, don’t change the slug!

    Cheers!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Map post from different post type name’ is closed to new replies.