Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomas-thackery/6ecc04fc96393998624fa331e5987747 to your computer and use it in GitHub Desktop.
Save thomas-thackery/6ecc04fc96393998624fa331e5987747 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 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment