[Resolved] Hook after header a menu item

Home Forums Support [Resolved] Hook after header a menu item

Home Forums Support Hook after header a menu item

Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • #907073
    Leo
    Staff
    Customer Support

    Conditional tag shouldn’t have caused that.

    Where can I see the issue?

    The page you linked has ID 3914 which isn’t included in the conditional tag.

    #907088
    Sebastien

    I’ve linked the page ID: 36

    as you see, the hook secondary nav bar is displayed under top bar. It also happens on pages that are not included in the conditional function.

    #907091
    Leo
    Staff
    Customer Support

    Hmm weird.

    I noticed that there is double ; after this line:
    add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 15 );;

    Can you fix that and see if it makes a difference?

    #907096
    Sebastien

    I’ve edited as suggested, but nothing changes. The code is now :

    add_action( 'after_setup_theme','lh_move_secondary_navigation' );
    function lh_move_secondary_navigation() {
        if ( is_page( array( 4536, 4537, 36, 4538, 4534, 4535 ) )  ) {
        remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 );
        add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 15 );
        }
    }
    #907099
    Leo
    Staff
    Customer Support

    Try this:

    add_action( 'wp','lh_move_secondary_navigation' );
    function lh_move_secondary_navigation() {
        if ( is_page( array( 4536, 4537, 36, 4538, 4534, 4535 ) )  ) {
            remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 );
            add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 15 );
        }
    }
    #907113
    Sebastien

    Ok this one works thanks.
    But If the conditon is not validate, I would like the second nar bar been hidden.

    #907119
    Leo
    Staff
    Customer Support

    Try this:

    add_action( 'wp','lh_move_secondary_navigation' );
    function lh_move_secondary_navigation() {
        if ( is_page( array( 4536, 4537, 36, 4538, 4534, 4535 ) )  ) {
            remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 );
            add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 15 );
        }
        else {
            remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 );
        }
    }
    #907123
    Sebastien

    Thanks you so much Leo !! it works =)
    Just for information: does this kind of php conditional add any delay in the page load performence?

    thanks byee =)

    #907133
    Leo
    Staff
    Customer Support

    Should be minimal.

    Glad we could help 🙂

Viewing 9 posts - 16 through 24 (of 24 total)
  • You must be logged in to reply to this topic.