WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Permalink Slugs in multiple languages

[Resolved] Permalink Slugs in multiple languages

Viewing 6 replies - 1 through 6 (of 6 total)
  • this isn’t available at the moment however maybe this can give you an idea – http://wordpress.org/support/topic/plugin-events-manager-date-in-the-permalink?replies=9

    that reference is great to change an event permalink, however I’m trying to modify Events Categories which does not seem to be possible as there is no such a hook as ’em_event_categories_get_permalink’

    Plugin Author Marcus

    @netweblogic

    isn’t this something your ML plugin would/should handle? for example i believe WPML does this already.

    we get that permalink using normal WP methods, e.g. $this->link = get_term_link($this->slug, EM_TAXONOMY_CATEGORY); within classes/em-category.php

    EM_TAXONOMY_CATEGORY is decided in em-posts.php, which you could hook into and intercept the option value using option_… filter.

    we could add a filter if that’d help.

    I think I didn’t explain myself properly, let’s say I have a multilingual site, Spanish as main language, English as second. I go to
    Events > Settings > Pages > Permalink Slugs
    and set Event Categories field to:
    eventos/categorias
    So my event categories will have the following urls:
    http://mysite.com/eventos/categorias/conciertos

    The problem is that in English I get:
    http://mysite.com/en/eventos/categorias/concerts

    The events/categories part cannot be translated afaik

    By the way, thanks for your time!!!

    I just hooked into EM_TAXONOMY_CATEGORY_SLUG which is defined in em-posts.php and which I think is the one I need to change to alter the URL. It seems to work on Events > Settings > Pages > Permalink Slugs, the Event Categories field changes for English and Spanish, however it does not work anywhere on the site, I still get:

    es-ES: http://mysite.com/eventos/categorias/conciertos
    en-US: http://mysite.com/en/eventos/categorias/concerts

    This is the filter I’m using:

    function em_wpml_dbem_taxonomy_category_slug($option){
        $lang = get_bloginfo('language');
    
        if( $lang === 'es-ES' ){
            $option = 'eventos/categorias';
        } else {
            $option = 'events/categories';
        }
        return $option;
    }
    add_filter('pre_option_dbem_taxonomy_category_slug', 'em_wpml_dbem_taxonomy_category_slug');

    add_filter(‘option_dbem_taxonomy_category_slug’, ’em_wpml_dbem_taxonomy_category_slug’);
    Note that I used a pre_option and option filter to just to make sure, in case the option_ was not enough…

    It seems like the plugin is using the database option value to build all urls and this bypasses my filter, is that so?

    Plugin Author Marcus

    @netweblogic

    ok, I’m assuming you’re using WPML here.

    I’m working on solutions to WPML at the moment, but haven’t gotten as far as taxonomies yet. However, as far as I’m aware wpml allows you to translate custom taxonomies from witihin the WPML settings.

    btw, in your code above, pretty sure you want to use something like

    global $sitepress;
    $sitepress->get_current_language();

    and use two char codes, e.g. ‘es’

    probably why it’s always defaulting to english

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Permalink Slugs in multiple languages’ is closed to new replies.