Support » Fixing WordPress » wp_nav_menu Custom Walker Issue

  • Hey folks,

    I’m attempting to implement a custom wp_nav_menu walker in WordPress 4.2.2. For some bizarre reason, regardless of what example code I draw from – and I’ve tried pretty much all of ’em – some the basic information isn’t present.

    For example, in the start_el(&$output, $item, $depth, $args) function, the $item argument doesn’t seem to pass anything that can be returned.

    Function in class

    function start_el(&$output, $item, $depth, $args) {
    		global $wp_query;
    		$classes = empty( $item->classes ) ? array() : (array) $item->classes;
    		$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
    		$class_names = ' class="'. esc_attr( $class_names ) . '"';
    		$output .= '<li id="menu-item-'.$item->ID.'"'.$value.$class_names.'>';
    		$item_output = '<a'. $item->url .'>'.$item->title.'</a>';
    		$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
    	}

    Output HTML

    <li id="menu-item-122" class=""><a></a></li>

    Does this problem sound familiar to anyone?

    Thanks!
    Mark

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_nav_menu Custom Walker Issue’ is closed to new replies.