Is there any way to pass a variable from start_el to start_lvl? I want to place the menu description in the wrapper of the submenu items.
class submenu_walker extends Walker_Nav_Menu
{
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("t", $depth);
$output .= "n$indent<ul class='sub-menu'><div class='menu-image-container'><div class='menu-image'></div></div>n";
}
function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("t", $depth);
$output .= "$indent<div class='clear'></div></ul>n";
}
}
I’ve tried to store the description as a variable in start_el, and access it using global in start_lvl… but it returns nothing.
I’m really desperate for help on this, as so far I’ve had no results, or responses to this question in terms of answers.
Can someone please help me with this? There are definitely some of you who know how to use the WordPress walker menu.
Here is the way to use this code and it will display the parent description.
Steps for using of it.
1: Copy the below class and past into the functions.php file.
2: Call the menu like
3:See the result.
Now after updating this function, your menu will show the parent menu description.
Here is the code.
Thanking you.
I have managed to find the solution to this question that seemed to go unanswered for days here – How can I add parent menu description to my WordPress menu?