How to display dynamic content in start_lvl function

I am creating a custom nav walker but having trouble outputting parent menu item title in start_lvl function. I want to output it right after the <div class=”dropdown”> in the following start_lvl function. function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat(“\t”, $depth); if ($depth == 0) { $out_div = ‘ <div … Read more

Adding ‘active’ class to custom taxonomies using walker in functions.php

I’m trying to use the following code in functions.php in order to show a menu with categories (custom taxonomies actually). I simply want it to show active when on the current page. What am I doing wrong? I also see that the $category = get_category($mycatid); line doesn’t populate the $category variable. <?php class walker_archives extends … Read more

Benefits of using Nav Walker?

Are there any benefits to using a nav walker class over iterating through wp_get_nav_menu_items()? Nav walkers seem very clunky to me and iterating over an array feels easier and more re-usable but it then bypasses the internal menu filters of wordpress that I don’t know much about. Will this make my theme incompatible with some … Read more

Indirect modification of overloaded property WP_Post::$classes has no effect

I’m working on a child theme and while everything works the Walker_Nav_Menu and Walker classes are causing all the fuss. My parent theme overrides Walker_Nav_Menu as below: if ( ! class_exists( ‘Zen_Menu_Walker’ ) ) { class Zen_Menu_Walker extends Walker_Nav_Menu { public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { $element->has_children = … Read more

`start_el` depth argument in custom nav walker always evaluates to zero

I have a custom nav walker I’m trying to use to output only the first level of a menu: <?php wp_nav_menu( array( ‘theme_location’ => ‘secondary-menu’, ‘depth’ => 1, ‘walker’ => new SecondaryNavWalker ) ); ?> However, all levels of the navigation are outputted regardless. I’ve tried doing a check against the arg in start_el, but … Read more