• I hope this isn’t a repeat of a dumb question; I was unable to find what I need anywhere, even though I feel reasonably sure this isn’t that complicated and I may have even done it before.

    I want to include the title of the menu as the first list element of the menu. I have a shortcode function for [menu name=”Footer Menu”] that finds the named menu, then displays it. I want to be able to also insert the name “Footer Menu” as the first list element on the menu. I started writing a custom Walker for this, but then realized I had no idea how to change the output prior to start_el. The function start_lvl only applies to child menus, so it didn’t work for this purpose.

    <ul>
    <li><h4>Menu Title</h4></li>
    ....menu items...
    </ul>

    Thanks in advance for any advice.

Viewing 1 replies (of 1 total)
  • Hi @twistysnacks, you have created the custom shortcode, right? So in call back function, you have to add attributes in the shortcode function like:

    $atts = shortcode_atts( array(
            'title'   => 'add default title here'
        ), $atts ); 

    And then you can call this attributes in your HTML like:

    <ul>
    <li><h4><?php echo esc_html($atts['title']); ?></h4></li>
    ....menu items...
    </ul>
Viewing 1 replies (of 1 total)

The topic ‘Include Menu Title/Heading’ is closed to new replies.