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.

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>";

}
share|improve this question
1  
Please show us your complete custom walker and how you determine the sub-menus that need extra content. –  toscho 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
add comment

1 Answer 1

You need to extend the Walker Class, not just include the functions. See Manipulating menu HTML for more.

share|improve this answer
add comment

Your Answer

 
discard

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

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