Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #3736
    Jordi Altimira
    Participant

    Hi,
    It would be nice change the permalinks so that ‘slugs’ change coherently as the language changes.

    Thanks in advance!
    Jordi :)

    #3738
    Bartosz
    Keymaster

    Totally agree.

    But neither WPML nor Polylang support that functionality. WPML has support for basic permalinks structure translations (post type slug) but this is still very basic and doesn’t work in more complex structures, like the one used in Events Maker.

    We’ve suggested this to guys form WPML a couple of times – no response from them till now.

    #3740
    Bartosz
    Keymaster

    As for now we’re doing this with some url rewriting in WP.

    This code may be useful if you translated the permalinks to your language, but want to use english as a secondary language (if otherwise, just change the lang=en to desired language code):

    // Adding rewrite rules for events post type in english
    function df_add_events_rewrite_rules() {
    	add_rewrite_rule('events/?$','index.php?post_type=event&lang=en','top'); // events archive
    	add_rewrite_rule('events/page/([0-9]{1,})/?$','index.php?post_type=event&paged=$matches[1]&lang=en','top'); // events archive with pagination
    	add_rewrite_rule('events/([0-9]{4}(?:/[0-9]{2}(?:/[0-9]{2})?)?)/?(?:page/([0-9]{1,})/?)?$','index.php?post_type=event&event_ondate=$matches[1]&paged=$matches[2]&lang=en','top'); // events date archive
    	add_rewrite_rule('events/event/([^/]+)/?$','index.php?post_type=event&event=$matches[1]&lang=en','top'); // single event
    	
    }
    add_action('init', 'df_add_events_rewrite_rules');

    This can be adjusted for event categories, tags, organizers and locations as well.

    I’m not sure but I think for Polylang you need to change the “lang=en” parameter to “language=en”.

    #3742
    Jordi Altimira
    Participant

    I’m sorry to hear that :(
    I didn’t thought was that difficult. Never mind and thank you for the code.

    #5504
    hx2000
    Participant

    That works perfectly here with Polylang 1.6. What exactly is the problem?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.