$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>menus - WordPress wp_nav_menu with a nav tag|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

menus - WordPress wp_nav_menu with a nav tag

matteradmin9PV0评论

I'm thinking about wrapping the wp_nav_menu with a nav tag instead of a div tag.

I've read at the WordPress codex that the container argument is only for using ul or div.

Do you guys know a way how to display the navigation in a nav tag so that the output looks like this:

<nav class="menu-header-menue-container">
  <ul id="menu-header-menue" class="menu">
    <li id="menu-item-86" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-86"><a href="home"></a></li>
  </ul>
</nav>

I'm thinking about wrapping the wp_nav_menu with a nav tag instead of a div tag.

I've read at the WordPress codex that the container argument is only for using ul or div.

Do you guys know a way how to display the navigation in a nav tag so that the output looks like this:

<nav class="menu-header-menue-container">
  <ul id="menu-header-menue" class="menu">
    <li id="menu-item-86" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-86"><a href="home"></a></li>
  </ul>
</nav>
Share Improve this question edited Jan 22, 2019 at 21:34 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Jan 22, 2019 at 21:23 MisterLAMisterLA 257 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

You were really close.

There is container argument for wp_nav_menu:

'container' (string) Whether to wrap the ul, and what to wrap it with. Default 'div'.

Its default value is 'div', which means, that the ul will be wrapped with div tag. You can change it to false - ul won't get wrapped at all in such case.

But you can also change it to nav - and that is what you're looking.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far