How to display Secondary Navigation menu only on single Posts in Genesis

Posted on

In GenesisWP Facebook group, a user asked:

does anyone know of a good way to have a secondary nav menu display on single post template pages- and nowhere else? Or- perhaps on a few other select pages?

Adding the code below in child theme’s functions.php will display a menu assigned to Secondary Navigation Menu location only on single Posts and nowhere else:

// Show the custom menu assigned to Secondary Navigation Menu location only on single Posts
add_action( 'genesis_header', 'sk_show_secondary_navigaton' );
function sk_show_secondary_navigaton() {
	if ( is_singular( 'post' ) ) {
		return;
	}

	remove_action( 'genesis_after_header', 'genesis_do_subnav' );
}