Site logo

Archived topic

Hook after header a menu item

23 replies · Started by Sebastien on May 21, 2019

Viewing posts 16–24 of 24

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.

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.

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?

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 );
    }
}

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 );
    }
}

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

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 );
    }
}

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 =)

Should be minimal.

Glad we could help :)

This archived topic is closed to new replies.