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.
Thread Starter
Suika
(@suikalum)
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?
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.
Thread Starter
Suika
(@suikalum)
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!
OK, thanks for sharing this info!
Thread Starter
Suika
(@suikalum)
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!