askdesign
1/21/2016 - 10:13 PM

How to Reposition Primary Navigation conditionally in Genesis

January 21, 2016 by Sridhar Katakam

// Reposition the primary navigation menu conditionally
add_action( 'genesis_before', 'sk_resposition_primary_nav' );
function sk_resposition_primary_nav() {

	// if we are not on a single Post page or archive page or search results page, abort.
	if ( ! ( is_singular( 'post' ) || is_archive() || is_search() ) ) {
		return;
	}

	remove_action( 'genesis_after_header', 'genesis_do_nav' );
	add_action( 'genesis_before_header', 'genesis_do_nav' );

}
We can place the reposition code inside a function hooked at a location that is immediately above the top most hook (contained inside the function) so an if conditional can be set.

While the tutorial has been written for Genesis Sample child theme it should work with minor adjustments in any Genesis child theme.

Adding the following in child theme’s functions.php will place the Primary Navigation above the header on single Posts, archives (incl. category pages) and search pages: