Site logo

Archived topic

Secondary Nav Before Main Content

3 replies · Started by David on March 21, 2019

Viewing posts 1–4 of 4

I'm relatively new to WP and GP so bear with me. I would like to have my secondary navigation be displayed before main content. I have found this code snippet:

add_action( 'after_setup_theme', 'lh_move_secondary_nav' );
function lh_move_secondary_nav() {
    remove_action( 'generate_before_header', 'generate_add_secondary_navigation_before_header', 7 );
    add_action( 'generate_after_footer_widgets', 'generate_add_secondary_navigation_before_header', 7 );
}

I understand that if I have my secondary nav set to above header and change this code snippet to generate before main content, this should work. I am assuming this is done in function.php? I am wondering is this also possible to do by creating a new hook element?

Thanks,
David

Hi there,

that is correct, that snippet would either go in you child theme functions.php or code snippets plugin:

https://docs.generatepress.com/article/adding-php/

To use a hook:
1. Set Navigation Location to No Navigation in Customizer > Layout > Secondary Nav.
2. Create a Hook Element, Select your Hook, Check Execute PHP, Set your display rules.
3. Add this to content:

<?php generate_secondary_navigation_position(); ?>

If you were to us a Hook that is full width such as the inside_container you can wrap the function like so:

<div class="second-nav grid-container">
	<?php generate_secondary_navigation_position(); ?>	
</div>

That worked thanks! May continue to play around with it until I determine exactly what I want, but I think I understand the concept better now.

You're welcome

This archived topic is closed to new replies.