Skip to content

Instantly share code, notes, and snippets.

@adamcbrewer
Created March 14, 2012 18:05
Show Gist options
  • Save adamcbrewer/2038280 to your computer and use it in GitHub Desktop.
Save adamcbrewer/2038280 to your computer and use it in GitHub Desktop.
WP: Custom Nav Menu's
<?php
/**
* Location: funtions.php
*
*/
// Registering in functions.php
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array(
'primary' => 'Primary Navigation', // 'slug_for_theme_location' => 'Label For Admin Section'
'secondary' => 'Secondary Navigation'
)
);
}
// Display the menu(s) in the header/template
// more help @ http://codex.wordpress.org/Function_Reference/wp_nav_menu
$args = array(
'theme_location' => 'primary', // slug from functions.php register_nav_menus()
//'menu' => 'primary', // hard-set the navigation
'container' => 'div', // menu wrapper element
'container_class' => 'menu-{menu slug}-container',
'container_id' => '', // default: none
'menu_class' => 'menu', // ul class
'menu_id' => '', // ul id
'echo' => true, // '0' to return menu instead of echo menu
'fallback_cb' => 'wp_page_menu', // fallback in menu doesn't exist
'before' => '', // before <a>
'after' => '', // after <a>
'link_before' => '', // inside <a>, before text
'link_after' => '', // inside <a>, after text
'depth' => 0, // '0' to display all depths
'walker' => '' // ?
);
// call this where you want the menu
wp_nav_menu( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment