Site icon WP Smith

How to Add the SubNav or the Secondary Navigation to Certain Pages

Here's how to add the Secondary Navigation to certain pages with the various Genesis options including Fancy Dropdowns, depth, and order. Add this to your functions.php file.

[php]
//just in case: ensures subnav on Genesis Theme Settings is set to true/checked.
$genset=get_option('genesis-settings');
if (!$genset['subnav']) {
$genset['subnav']=1;
update_option('genesis-settings',$genset);
}
//Remove Subnav
remove_action('genesis_after_header', 'genesis_do_subnav');
add_action('genesis_after_header','my_custom_subnav');

function my_custom_subnav () {
$genset['subnav_superfish'] = 1; //1 = Enable Fancy Dropdowns, 0 = Disable
$genset['subnav_home'] = 0; //1 = Display home, 0 = Disable
$genset['subnav_type'] = 'categories'; // pages = List of Pages, categories = List of Categories, nav-menu = Custom Nav Menu
$genset['subnav_pages_sort'] = menu_order; // menu_order = Menu Order, post_title = Title, ID = ID, post_date = Date Created, post_modified = Date Modified, post_author = Author, post_name = Slug
$genset['subnav_categories_sort'] = post-title; // menu_order = Menu Order, post_title = Title, ID = ID, post_date = Date Created, post_modified = Date Modified, post_author = Author, post_name = Slug
$genset['subnav_depth'] = 0; // 0 = No Limit, 1, 2, 3, 4
update_option('genesis-settings',$genset);

$pages = array(1,2,3); //insert whatever page ids, slugs etc.
if (is_page($pages)) {
genesis_do_subnav();
}
}[/php]