Archiv

Archiv für November, 2011

WordPress 3.0 Menü und qtranslate

20. November 2011 Keine Kommentare

Problem:

Habe in letzter Zeit das Problem, daß qtranslate nicht Links im Menü von WordPress 3.0 automatisch übersetzt.

Lösung:

Einen Filter für das WordPress Menü (walker_nav_menu_start_el) hinzufügen in der functions.php des Themes:

 

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 .= ‘<a’. $attributes .’>’;
$item_output .= $args->link_before . apply_filters( ‘the_title’, $item->title, $item->ID ) . $args->link_after;
$item_output .= ‘</a>’;
$item_output .= $args->after;

return $item_output;
}

Quellen:

http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output/

http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=1746&start=0

Share
KategorienWissenswertes Tags: