Celebrating 7 Years! Get up to $30 off GeneratePress Premium!

[Resolved] Swap primary and secondary navigation

Home Forums Support [Resolved] Swap primary and secondary navigation

Home Forums Support Swap primary and secondary navigation

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #477461
    William

    Hello! I would like to swap the primary and secondary navigation bars so the secondary one is on top of the primary one. I know I could achieve this by simply switching their styles and contents, but I really like having the search bar on the primary navigation and having the primary navigation in “sticky” mode.

    I tried the following code to swap them, using the “Code Snippets” plugin :

    add_action( 'after_setup_theme','generate_move_secondary_nav' );
    function generate_move_secondary_nav()
    {
        remove_action( 'generate_before_header', 'generate_add_secondary_navigation_before_header', 7 );
        add_action( 'generate_before_header', 'generate_add_secondary_navigation_before_header', 4 );
    }

    The snippet definitely shows as “Active” and is set to “Run snippet everywhere”. I found this code as a suggested solution here : https://generatepress.com/forums/topic/secondary-navigation-2/ but it does not seem to have any effect on my Website. This thread is almost two years old so maybe something changed in the theme since then and this code is outdated? There is no custom CSS or added PHP code other than the snippet above.

    Thank you and have a nice day!

    GP Premium 1.5.6
    #477602
    Leo
    Staff
    Customer Support

    Hi there,

    Can you try this?

    add_action( 'after_setup_theme','generate_move_secondary_nav' );
    function generate_move_secondary_nav()
    {
        remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 );
        add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 4 );
    }
    #477689
    William

    Thank you for your reply.

    I replaced the code snippet with the one you provided but it unfortunately did not work. I tried disabling all my plugins except Code Snippets and GP Premium and still no luck.

    Would it be easier to put the search bar on the secondary navigation as well as making it sticky instead of the primary one using CSS?

    #478055
    Leo
    Staff
    Customer Support

    Made a mistake in the code. Try the edited version above. It should definitely work now.

    #478161
    William

    Perfect, this is it ๐Ÿ™‚

    Thank you for your help, I am marking this as resolved!

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