Skip to content

Instantly share code, notes, and snippets.

@zgordon
Last active January 7, 2024 05:15
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save zgordon/1ce2f7fc29f45665a8ffc22d64e220b1 to your computer and use it in GitHub Desktop.
Save zgordon/1ce2f7fc29f45665a8ffc22d64e220b1 to your computer and use it in GitHub Desktop.
Demo of the possible menu parameters for wp_nav_menu
<?php
$args = [
// Location pickable in Customizer
'theme_location' => 'main-menu',
// Assigns a default menu to location
'menu' => 'Main Menu',
// Main wrapper around the ul of posts
'container' => 'div',
'container_class' => 'container-class',
'container_id' => 'container-id',
// Wrapper for menu items - defaults to ul
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
'menu_class' => 'items-wrap-class',
'menu_id' => 'items-wrap-id',
// Add text to link text (inside a tag)
'link_before' => '',
'link_after' => '',
// Add text to link text (inside a tag)
'before' => '',
'after' => '',
// Depth of child nav items to show
'depth' => 0,
// Callback function if menu is not available
'fallback_cb' => 'wp_page_menu',
];
wp_nav_menu( $args );
?>
@zgordon
Copy link
Author

zgordon commented Jul 26, 2017

Not included:

  • fallback_cb
  • walker

@BesmellahBassam
Copy link

Seems good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment