I'm trying to add unique content to the end of each dropdown (sub-menu). I've managed to edit the end_lvl function of the walker class to add the div to the end of each sub-menu, but now I'm lost on the next step: creating a conditional statement based on the parent-menu-id to echo different content. Any thoughts/suggestions? This is what I have (and I know its obviously not working because I'm trying to use the item array but with menu-parent-id). Clearly I don't quite understand this.

function start_lvl( &$output, $depth = 0, $args = array() ) {
    $indent = str_repeat("\t", $depth);
    $output .= "\n$indent<div class=\"sub-menu\">\n<ul>";

function end_lvl( &$output, $depth = 0, $item, $args = array() ) {
    $indent = str_repeat("\t", $depth);

     if($item->menu-item-parent==37) {
        $afterMenuContent = "Content";
    $output .= "$indent</ul>\n<div class=\"after-menu\">" . $afterMenuContent . "</div>\n</div>";


closed as off-topic by fuxia Apr 30 '15 at 22:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Please show us your complete custom walker and how you determine the sub-menus that need extra content. – fuxia Dec 28 '12 at 22:02
  • 1
    Can you explain what is going wrong with the code you posted? Nothing prints? Error message? Does $item->menu-item-parent give the correct IDs? – s_ha_dum Dec 28 '12 at 22:03
  • $item->menu-item-parent prints a zero all the time. – Joseph Michael Rstom Dec 28 '12 at 23:06
  • Also, toscho that is my complete custom walker, but I will update it. – Joseph Michael Rstom Dec 28 '12 at 23:07
  • You need to extend the Walker Class, not just include the functions. See wordpress.stackexchange.com/questions/39005/… for more. – benklocek Feb 25 '13 at 23:55



instead of


Can you show us the html output you want ?

Not the answer you're looking for? Browse other questions tagged or ask your own question.