Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Today I've written my own custom menu walker. While I am a bit shocked how difficult this is (also because there seem to be some bugs in Wordpress), I am astonished that I could make everything work. There is only one thing I can't figure out:

How do I print the description given to a menu item in the Wordpress backend as first item in a submenu?
Or maybe a bit simpler: How do I display the menu item description, but only if the menu has a submenu?

In my walker, I tried to modify start_lvl like this:

function start_lvl(&$output, $depth, $item) { 
    $description  =! empty( $item->description ) ? esc_attr( $item->description ) : '';

    // $depth > 0 could also work?
    $depth === 1 ? $output .= $description : '';

    $indent = str_repeat("\t", $depth);
    $output .= "\n$indent<ul class=\"navlist__sublist\">\n";

That didn't work (but also did not give me an error), probably because I added $item as argument. So I guess my approach is wrong, but how to properly do this?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.