• Resolved dl80

    (@dl80)


    I try to setup a MU blog with 2 different custom post types and 2 different custom taxonomies per post-type.

    to create the post-type and taxonomy structure, i created a tiny plugin and do different register_ -calls, depending on get_bloginfo(‘language’).
    So i can have separate slugs for the same post-type in different languages…

    to get MSLS to work, i have to use the same post-type-name over all languages, right?

    how do you recommend to build the taxonomy structure?

    different or same taxonomy names for all languages?

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

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

    (@realloc)

    You can use localized slugs if you want but you must – in this case – use the ‘msls_options_get_permalink’-filter to let the switcher know what’s going on.

    For example:

    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 );

    Source: http://msls.co/hooks-filters-and-actions/

    Cheers,
    Dennis.

    Thread Starter dl80

    (@dl80)

    Thank you for your quick reply.

    But this filter is only for different slugs, isn’t it?

    So far, I am registering a “products” (same name) post_type in both blogs but with different settings (labels, slugs) and it seems to be working.

    It is not possible to have a post_type “produkte” in the /de/ blog and a post_type “products” in the /en/ blog and link them, right?

    Sorry, I’m not sure if i’m really understanding it 😉

    Plugin Author Dennis Ploetner

    (@realloc)

    No … you can localize almost everything – labels and even slugs – but you cannot tie together different post types.

    Thread Starter dl80

    (@dl80)

    Thank you again!

    Do you know any guide of how such localization should be done?

    So far, i wrote a Plugin, which uses a simple switch:

    $currentlang = get_bloginfo('language');
     if($currentlang == "de-DE") {
    	require_once('de_posttypes.php');
    	require_once('de_taxonomies.php');
    	}
    	elseif ($currentlang == "en-US") {
    	require_once('en_posttypes.php');
    	require_once('en_taxonomies.php');
    	}
    	else {
    	add_action( 'admin_init', 'deactivate_plugin_conditional' );
    	}

    in these four plugin files, i do the different register calls with the same post_type name and the same taxonomy name but different labels and slugs depending on the language.

    is there any better way to achieve this?

    thank you for your convenient help!

    Plugin Author Dennis Ploetner

    (@realloc)

    Please have a look here: http://generatewp.com/post-type/

    This is much easier and you can then work with localization of your plugin: http://premium.wpmudev.org/blog/localize-a-wordpress-plugin-and-make-it-translation-ready/

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

The topic ‘recommended setup – custom post types with custom taxonomies’ is closed to new replies.