Created
June 19, 2012 22:32
-
-
Save chasereeves/2956909 to your computer and use it in GitHub Desktop.
Remove list from wordpress nav, replace with span
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p class="menu-main-menu-container"> | |
<?php wp_nav_menu( array( 'menu' => 'Main Menu','container' => false,'items_wrap' => '%3$s','walker' => new no_list_custom_nav_walker() ) ); ?> | |
</p> | |
class no_list_custom_nav_walker extends Walker { | |
var $tree_type = array( 'post_type', 'taxonomy', 'custom' ); | |
var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' ); | |
function start_lvl(&$output, $depth) { | |
$indent = str_repeat("\t", $depth); | |
$output .= "\n$indent<ul class=\"sub-menu\">\n"; | |
} | |
function end_lvl(&$output, $depth) { | |
$indent = str_repeat("\t", $depth); | |
$output .= "$indent</ul>\n"; | |
} | |
function start_el(&$output, $item, $depth, $args) { | |
global $wp_query; | |
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; | |
$class_names = $value = ''; | |
$classes = empty( $item->classes ) ? array() : (array) $item->classes; | |
$classes = in_array( 'current-menu-item', $classes ) ? array( 'current-menu-item' ) : array(); | |
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); | |
$class_names = strlen( trim( $class_names ) ) > 0 ? ' class="' . esc_attr( $class_names ) . '"' : ''; | |
$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 ) .'"' : ''; | |
$item_output = $args->before; | |
$item_output .= "<a". $attributes . $class_names .'>'; | |
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after; | |
$item_output .= "</a> "; | |
$item_output .= $args->after; | |
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); | |
} | |
function end_el(&$output, $item, $depth) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment