[Resolved] Move main menu below banner/header on single posts

Home Forums Support Move main menu below banner/header on single posts

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1382427
    Daniel

    I’m struggling to determine why my main menu is above my banner on Single Posts and the Blog page. I’ve set the Primary menu’s position to “Below Header” in the customizer (Layout > Primary Navigation). Is there a separate control for the Blog and/or single posts menu placement?

    I have two Elements with Header parameters. One displays on Front Page only, the other appears on all Pages (except Front), Posts and Blog.

    Thanks

    #1382692
    David
    Staff
    Customer Support

    Hi there,

    which code did you use to move the Navigation below the Header Element on the front page ?

    #1383135
    Daniel

    Hi,

    I didn’t use any special code to move the Navigation below the Header Element on the front page…as far as I can remember (it’s been awhile). Just the Layout controls in the Customizer. No special css adjustments or php in header.php.

    If you would like admin access, let me know how to send you credentials. Thanks.

    #1383394
    David
    Staff
    Customer Support

    This it the PHP Snippet that moves a after_header Primary Nav to below the Header Element:

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

    Check to see if you have any similar function in your child theme before adding it your site.

    #1383410
    Daniel

    Ah. I have this snippet:

    add_action( 'wp', function() {
        if ( is_page() ) {
            remove_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
            add_action( 'generate_after_header', 'generate_add_navigation_after_header', 15 );
        }
    } );

    It looks like this limited the change to pages. I’ll use your code instead, which works fine, thank you. Out of curiosity, how would I include posts and the blog page in the code I’m showing above?

    #1383415
    David
    Staff
    Customer Support

    The code i provided should work across the entire site – as long as they all have a header element.

    If you wanted to target specific parts of the site then you can you keep your code and add some additional conditional tags.

    https://codex.wordpress.org/Conditional_Tags

    e.g this line:

    if ( is_page() ) { is just Pages.

    Whereas this:

    if ( is_home() ) { is just the Blog Page ( Thats when the Blog is static page NOT the front page.

    And this:

    if ( is_home() || is_single() ) { is the Blog Page OR the single posts.

    You can string as many as you like or use the ! not statement.

    So this:

    if ( ! is_home() ) { would be everywhere except the Blog Page

    Hope that helps

    #1383419
    Daniel

    Yes, thanks again for the great support.

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