Hier eine kleine Walker Klasse für WordPress, um sich ein Menü in der Form “ Link1 | Link2 | Link3 “ zu erstellen.
Einfach die Klasse in die functions.php des Themes und den Menü Eintrag dort im Template platzieren, wo er hin soll.
<?php
wp_nav_menu(
array(
'container' => FALSE,
'menu' => 'The Footer Links',
'menu_class' => 'nav',
'theme_location' => 'footer-nav',
'items_wrap' => '<nav id="%1$s" class="%2$s" role="navigation">%3$s</nav>',
'depth' => 1,
'walker' => new Links_Walker_Nav_Menu()
)
);
class Links_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
//Add attributes to link element.
$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 ) . '"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) . '"' : '';
$attributes .= ( $item->current ) ? ' class="active"' : '';
$output .= ( $item->menu_order > 1 ) ? ' | ' : '';
$output .= '<a' . $attributes . '>';
$output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$output .= '</a>';
}
function end_el( &$output, $item, $depth = 0, $args = array() ) {
$output .= '';
}
}