Mqtranslate plugin and menu items

Mqtranslate plugin and menu items

Posted: 10 years ago in 


When using mqtranslate to make wordpress website multilingual, the child item in top menu is not translated. To fix that, add this snippet into functions.php in your active theme folder


When using mqtranslate to make wordpress website multilingual, the child item in top menu is not translated. To fix that, add this snippet into functions.php in your active theme folder

if (function_exists('qtrans_convertURL')) {

        function qtrans_in_nav_el($output, $item, $depth, $args) {
            $desc = __( $item->post_content );
        
            $output = preg_replace('/href="([^"]+)"/', 'href="'.esc_attr( qtrans_convertURL($item->url)).'"', $output);
            $ret = $output;        

            return $output;
        }
        add_filter('walker_nav_menu_start_el', 'qtrans_in_nav_el', 10, 4);
}

Problem Solved


    Tags: