WordPress.org

Ready to get started?Download WordPress

Forums

Using a Walker on Menu (1 post)

  1. MrAlexander.Ca
    Member
    Posted 3 years ago #

    Hello,

    I am trying to extend the way wp_nav_menu works by creating a simple walker yet I am having difficulties with it.

    Here is the class:

    class Walker_Menu_Float extends Walker_Nav_Menu {
    	function end_lvl(&$output, $depth) {
    		$indent = str_repeat("\t", $depth);
    		$output .= $indent . '<li class="float-divider">&nbsp;</li></ul>\n';
    	}
    }

    As you may see I have added a very minor details yet when I use this in my theme I dont see this addition added to my code.

    I tried modifying other functions, start_el, end_el and they work but this one doesnt.

    Here is the code in the theme:

    $walker = new Walker_Menu_Float();
    
    wp_nav_menu(array(
    	'menu' => 'Pests',
    	'container' => null,
    	'menu_id' => 'menu-pests',
    	'theme_location' => 'menu-pests',
    	'walker' => $walker
    ));

    Any help is highly appreciated.

    Thank you.

    Alexander

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by MrAlexander.Ca
  • This topic is not resolved
  • WordPress version: 3.0.1