[Resolved] dynamic header above menu

Home Forums Support [Resolved] dynamic header above menu

Home Forums Support dynamic header above menu

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #588643
    Michiel

    I want my primary navigation to appear underneath the dynamic header, both contained and the menu will not appear in a sidebar. Is there anyone who knows?

    #588650
    David
    Staff
    Customer Support

    Hi Michael,

    you can use this PHP snippet to move the navigation below the page header:

    add_action( 'after_setup_theme','craig_move_navigation' );
    function craig_move_navigation() {
        remove_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
        add_action( 'generate_after_header', 'generate_add_navigation_after_header', 15 );
    }

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

    Then its a case of setting the page header and primary navigation to contained

    #588656
    Michiel

    Yes, it works! Thanks!

    #588666
    David
    Staff
    Customer Support

    Glad i could help

    #588668
    Sridhar

    1. generate_header would be better than after_setup_theme as it is recommended to hook as late as possible.

    2. Nav bar can simply be hooked to generate_after_page_header at the default priority of 10 vs to generate_after_header at 15.

    add_action( 'generate_header','craig_move_navigation' );
    function craig_move_navigation() {
        remove_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
        add_action( 'generate_after_page_header', 'generate_add_navigation_after_header' );
    }
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.