How do I go about inserting a custom div before the wp_nav_menu() adds the ul?
That’s what the 'container'
array key defines: the element that contains the menu.
The menu will always output as a <ul>
, wrapped in a container of the type specified by the 'container'
array key: either a <div>
(default), by passing 'div'
; <nav>
, by passing 'nav'
; or none, by passing false
.
So, if you want to wrap your nav menu in a <div class="menu-button">
, use the following array arguments:
array(
'container' => 'div',
'container_class' => 'menu-button'
)
(Though, again, 'div'
is the default value, so you can omit it if you want.)
Related Posts:
- Dynamically exclude menu items from wp_nav_menu
- Add custom menu item using wp_nav_menu_items filter
- Custom search filter causes menu and query_posts problems
- Unregister Nav Menu from Child-Theme
- Allow html tags in WordPress Custom Menus Description Field
- Using filters to change href of nav menu page link
- How to apply a class to the second word in menu list item?
- WordPress nav_menu_link_attributes Not Working
- Is it possible to add a filter for the output of nav-menu items in admin?
- if role is logged in then do something
- Filter menu item to add classes/attributes?
- Edit html for menu items in default frontend menu
- Set Item Order with wp_nav_menu_{$menu->slug}_items
- When at / ( or “home”) my menu doesn’t get a current-menu-item class
- How to add parent element’s title to nav menu’s child?
- Why is ‘nav_menu_item_args’ filter’s $item argument empty?
- Add class to active element and its parent in nav menu
- display only the wp_nav_menu, which has the current-menu-item
- Removing strip_tags not working on nav_menu_description
- Third level navigation class
- How to add #navbar to all page links?
- add span to top level links of a wordpress menu called “main”
- Debugging – trying to add search box to menus
- wp_list_pages() but only show children on the branch you are on
- From a page, is it possible to find entry’s “menu_item_parent”?
- Add active class to top-level menu items when viewing single for that post type
- add_filter on menu items to add a menu item
- how to disable default menu classes
- Insert other menus as submenus of a main menu
- list category posts under its item in menu
- Prevent menu from loading in a page template [duplicate]
- How to change menu structure?
- Secondary Navigation Menudisappeared When using wp_nav_menu_items
- remove specific classes from menu items
- wp_nav_menu action/filter help
- add_filter for where statment issue
- Add a counter beside menu item label
- Add custom link on the fly to nav menu
- menu-item class missing on wordpress menu
- Filter to hook into menu items and add a custom attribute
- if role is logged in then do something
- Possible to append class to nav menu added to widget area?
- Modifying Woocommerce menu based on tags and categories
- Why does WordPress convert absolute URLs to relative URLs for menu items?
- Menu location switcher – example code fails
- Add Featured Image and Title to wp_nav_menu items
- Show thumbnail to category items in wp_nav_menu(), how?
- Add Class to Custom Menu Widget ul
- Avoid changing menu query with suppress_filters => false
- Removing menu item doesn’t get removed on edit post
- Add Protocol to Custom Menus
- How to modify menu text in callback function of ‘walker_nav_menu_start_el’ hook
- Why is WordPress stripping anchor links from mneu item URLs?
- Add button and title on submenu WordPress
- Display only page specific sub menu items using Custom Walker
- non-clickable placeholder in the menu
- Ways to give a wp_list_pages menu link specific class names?
- I want remove last after wp_nav_menu
- wp_list_pages – show pages immediately 1 level below current level
- Vertical Sidebar Menu Parent and Child not displaying correctly [closed]
- How to show Home Page link in WordPress Menu and how to add an icon to this?
- Run a filter when a walker runs
- How do you return a menu with the menu name?
- do_action appearing outside of menu?
- You do not have permission to create Navigation Menus – Twenty Twenty-Two theme
- Walker class conditional based on parent menu item label or custom css class
- ‘wp_get_nav_menu_items’, when fired inside of the ‘wp_update_nav_menu’ hook, returns old menu items, instead of new
- Walker Class – Check if menu item has description and if so add class to li
- Multiple languages menus problem
- How to override menu markup?
- How to remove dropdown from wp_nav_menu
- Insert a div class inside wordpress menu
- How to make wordpress nav menu use post custom meta data
- Is it possible to make the heading on a page different text to the text of the menu item?
- How to Structure Pages and Subpages
- CTA button that is only visible to some of my users
- add another html tag after li element in wp_nav_menu
- How do I change/remove styling (top border) on main menu for active page and hovering (Avada Theme)
- WP nav menu + Bootstrap, add role=”menu” to UL
- how to set the link in wordpress such that on clicking it doesn’t open another page but go to the bottom of same page
- custom walker class for own menu?
- Add a menu metabox to post edit page
- Setting or plugin for showing submenus horizontally under the main menu, and keep them after selection
- New wp menu menu styling
- (Mobile) Hamburger menu disappeared from a page (only one)
- Hiding menu on specific pages
- Bootstrap Menu bar shows up a toggle in Desktop Mode
- For a menu custom link (without a link) a “#” is appended. Can this just be blank, i.e. NO link?
- sidebar navigation problem with child pages not all display.?
- How to point menu to my homepage
- save_post() on Menu Save
- update_post_meta breaking wp_update_nav_menu_item
- Building a menu from a large number of pages?
- How do I remove a menu from a theme?
- Access CSS Classes specified in Menu options
- Custom Menu based off custom header
- Adding an additional menu in WordPress
- Making current_page_item work with wp_list_pages in sidebar on post pages
- Sub menu for a (single) page
- change breakpoint widths for divi theme tablet view