suikalum on "[Plugin: Multisite Language Switcher] Map post from different post type name"

ساخت وبلاگ

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/

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.

suikalum
Member
Posted 21 hours ago #

I tried to use this:

function my_msls_options_get_permalink( $url, $language ) { if ( 'en_GB' == $language ) { $url = str_replace( '/sanitizers/', '/sanitisers/', $url ); } retu $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.

suikalum
Member
Posted 14 minutes ago #

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!

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 247 تاريخ : پنجشنبه 20 خرداد 1395 ساعت: 10:29