WordPress Links Menü Walker Geschrieben in WordPress und getagged mit Menu, Script, Walker, WordPress am 19.09.2012. Schreibe einen Kommentar 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. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 .= ''; } } view raw wp-links-menu.php This Gist brought to you by GitHub.