How to remove trailing </li> tags from wp_nav_menu walker

I trying to migrate my website to Word press and I am stuck with a problem that when I use the example given by RCV ( WordPress change header navigation list items to div ) I get trailing </li> tags and I can’t figure out how to remove them, this is the output I get.

<div class="top-left home">
    <div class="frame1">
        <a href="index.html"><span class="click"></span></a>
    </div></li>
    <div class="frame2"><h1 class="fittext1">Text<br/>Text<br/>Text</h1></div></li>
    <div class="frame3"><a href="Photo-price/index.html"><span class="click"></span></a>
        <h3 class="fittext3 bottomfull">text<span class="rightfull">></span></h3>
    </div></li>
</div>

any help would be most appreciated

Related posts

Leave a Reply

1 comment

  1. You’re getting the trailing li tag because you’ve added the start_el method to your custom walker but you haven’t added the end_el so it’s using the default. Add the following to your custom walker class.

    function end_el( &$output, $item, $depth = 0, $args = array() ) {
        $output .= "</div>n";
    }
    

    You will then need to remove the closing div tag from your start_el. Alternatively you could set end_el to $output .= “”; but this isn’t recommended.