Open the „nav-menu-template.php“ in the wp-include-directory and add this code at the end of the file:
add_filter('wp_nav_menu_items','qtrans_in_nav_function');
function qtrans_in_nav_function ($nav){
$url = get_bloginfo('url');
$url_preg = preg_replace('/\//', '\/', $url);
$qtrans_url = qtrans_convertURL($url);
$nav = preg_replace('/('.$url_preg.')(\/id)/', $url, $nav);
$nav = preg_replace('/('.$url_preg.')/', $qtrans_url, $nav);
return $nav;
}
This code doubles the /de/de/ entry, so this is short, but errorful 🙁
This code fixes it:
add_filter('walker_nav_menu_start_el', 'qtrans_in_nav_el', 10, 4);
function qtrans_in_nav_el($item_output, $item, $depth, $args){
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
// Determine integration with qTranslate Plugin
if (function_exists('qtrans_convertURL')) {
$attributes .= ! empty( $item->url ) ? ' href="' . qtrans_convertURL(esc_attr( $item->url )) .'"' : '';
} else {
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
}
$item_output = $args->before;
$item_output .= ' $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= '';
$item_output .= $args->after;
return $item_output;
}
Thats it
http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=1746
http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=3&p=15
http://wordpress.org/support/topic/plugin-qtranslate-more-link-always-points-to-default-language
Leave a reply