• I’m trying to extend WordPress Walker.

    Custom walker I included works (I make some simple changes to the class and it applies, so I know I created custom walker properly and it’s all connected), but what I’m trying is adding additional list item (li) after the last one, so I tried this (this is only part of the whole walker code of course):

    public function end_lvl( &$output, $depth = 0, $args = array() ) {
    $indent = str_repeat("\t", $depth);
    $output .= "$indent<li>custom content</li></ul>\n";
    }

    You can see I added custom content (li) before closing list however this doesn’t show up on the site. Again some other simple changes do show, so I know custom class works, however I cannot add this additional li before closing ul.

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • public function end_lvl( $output, $depth = 0, $args = array() ) {
    $indent = str_repeat("\t", $depth);
    $output .= $indent . "<li>custom content</li>";
    }

    make sure that you understand delimeter

    Thread Starter jovboz

    (@jovboz)

    Thanks mrjhon01!

    One question, why do you change &$output to $output?

    Jovana

    I don’t think so that there’s a syntax like.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add custom element at the end of Walker Nav Menu’ is closed to new replies.