-
Notifications
You must be signed in to change notification settings - Fork 7
Adding Theme Support for Primary Navigation Menus
mgburns edited this page Mar 10, 2013
·
9 revisions
Activating the navigation plugin will immediately improve the user experience for managing your site hierarchy.
With a little help from your theme, the structure set with these interfaces can automatically feed your sites primary navigation menu.
To begin, register theme support for primary navigation by adding the following to functions.php
:
<?php
add_theme_support( 'bu-navigation-primary' );
Adding this line will reveal the "Appearance > Primary Navigation" menu screen.
To display the primary navigation menu, add the following to the template file responsible for displaying the menu (typically header.php
):
<?php if ( function_exists( 'bu_navigation_display_primary' ) ) {
bu_navigation_display_primary();
}
This function takes several optional arguments:
$defaults = array(
'post_types' => array( 'page' ), // post types to display
'include_links' => true, // whether or not to include BU Navigation links with pages
'dive' => true, // whether or not to display descendants
'depth' => 1, // how many levels of descendatns to display
'max_items' => 6, // how many items to display per list
'container_tag' => 'ul', // HTML tag to use for menu container
'container_id' => 'nav', // HTML ID attribute of menu container
'container_class' => '', // HTML class attributes for menu container
'item_tag' => 'li', // HTML tag to use for individual menu items
'identify_top' => false, // If set to true, uses post name as HTML ID attribute for top level posts
'whitelist_top' => null, // optional string or array of post names to whitelist for top level
'echo' => 1 // whether to display immediately or return
);