start_lvl ignored in custom walker_nav_menu (4 posts)

  1. fenfe1
    Posted 3 years ago #


    This is my first project involving wordpress and i've got stuck trying to create a custom walker for a footer menu.

    I basically want to change the menu from the <ul> <li></li> </ul> structure to a <p> <span></span> </p> structure.

    The menu and stuff is displaying file and I have been able to adjust the start_el and end_el functions without issue so I now get this:

    <ul> <span>*link*</span> <span>*link*</span> </ul>

    Which is obviously half way there, I have written the start_lvl() and end_lvl() tags as shown below but they are ignored by wordpress - nothing I put in them (even die()) is executed (which is a bit suspicious) but I know the class is being called because of the start_el() function.

    function start_lvl(&$output, $depth = 0, $args = array()) {
    $output = "\n<p class=\"sub-menu\">\n";

    function end_lvl(&$output, $depth = 0, $args = array()) {
    $output .= "\n</p>\n";
    Does anyone know why this is happening - have I missed something really obvious!?

    I am running the latest version of wordpress on apache with php 5.3.6 if it helps.

    Thanks in advance,

    Felix :)

  2. Luca Maroni
    Posted 2 years ago #

    Hi Felix. did you solved your issue? If yes can you send me some tips? I'm facing the same problem? Thank you in advance

  3. Andrew
    Forum moderator
    Posted 2 years ago #

    Lukennon, if you need support, create your own thread.

  4. Matt Thiessen
    Posted 2 years ago #

    Your my_extended_walker class is OK, but when you call the wp_nav_menu function use the items_wrap parameter.

    wp_nav_menu( array( 'items_wrap' => '<p>%3$s</p>', 'walker'=>new my_extended_walker() ) );


    The start_lvl is used for children elements.

Topic Closed

This topic has been closed to new replies.

About this Topic