How to change ?lang=cn into /cn/

I’m trying to add languages to my wordpress driven website and i installed xili-languages plugin. Unfortunately it uses lang param to differentiate between languages and i rather have seen something like http://domain.com/cn/article-in-chinese/ rather than http://domain.com/article-in-chinese/?lang=cn

2 Answers
2

Set permalink to (Post Name)

or

http://www.example.com/[blog_name]`/%post_id%/%postname%/`

Add following code to functions.php of your theme:

add_filter ( 'alias_rule', 'xili_language_trans_slug_qv' ) ;


function xl_permalinks_init () {
    global $XL_Permalinks_rules;
    if (class_exists('XL_Permalinks_rules') ) {
        $XL_Permalinks_rules = new XL_Permalinks_rules ();
        add_permastruct ( 'language', '%lang%', true, 1 );
        add_permastruct ( 'language', '%lang%', array('with_front' => false) );

    }
}

Leave a Comment