[Resolved] Secondary Nav Before Main Content

Home Forums Support [Resolved] Secondary Nav Before Main Content

Home Forums Support Secondary Nav Before Main Content

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #845911
    David

    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

    GeneratePress 2.2.2
    #845986
    David
    Staff
    Customer Support

    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>
    #846465
    David

    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.

    #846637
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.