WordPress.org

Ready to get started?Download WordPress

Forums

Multisite Language Switcher
[resolved] Custom Post Types and MLS (4 posts)

  1. MattV
    Member
    Posted 1 year ago #

    Thanks for this great plugin!

    Quick question: what´s the best way to localize custom post types?

    At the moment I have set up two different post types: activities (en_US) and actividades (es_ES).

    This results in this permalink structure:

    1. example.com/activities/english-activity/
    2. example.com/es/actividades/spanish-activity/

    I´d like to connect the English post type to the Spanish post type.

    I´ve used your permalink filter in the functions.php file of my Spanish site and updated permalinks settings. However MLS doesn´t seem to find a translatable post yet.

    I´ll look into this further, just wondering if you could tell me if I´m on the right track or if I should take a different approach.

    Here´s the filter I used:

    function my_msls_options_get_permalink( $url, $language ) {
        if ( 'es_ES' == $language ) {
            $url = str_replace( '/activities/', '/actividades/', $url );
        }
        return $url;
    }
    add_filter( 'msls_options_get_permalink', 'my_msls_options_get_permalink', 10, 2 );

    http://wordpress.org/extend/plugins/multisite-language-switcher/

  2. realloc
    Member
    Plugin Author

    Posted 1 year ago #

  3. MattV
    Member
    Posted 1 year ago #

    Interesting. I just learnt that we can also dynamically set the slug based on the WP_LANG language when registering a custom post type. I´ll try that tomorrow and paste my final solution here.

  4. side777
    Member
    Posted 1 year ago #

    to get the dynamically generated slug of a custom post type (archive) you can use:

    $obj = get_post_type_object('post_type');
    $slug = $obj->rewrite['slug'];

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.