Remove Nav Menu From Front Page & Single Pages Exclude Blog Page

This post written for a member shows you how to remove the primary nav menu in the after header position from your front page and all single pages.

There’s 2 steps involved:

  1. Add a custom function to conditionally remove the menu from the front and single pages.
  2. Create a custom blog page template to add back the menu to any pages using the blog page template.

The reason you need to add the menu back is because the is_page() or is_singular('page') conditional tags remove the menu from any pages using the page body class which includes the blog page template which you can view in the source code.

Add the 1st code snippet to your child themes functions file, at the end of the file.

add_action('get_header', 'child_remove_genesis_do_nav');

function child_remove_genesis_do_nav() {
if ( is_front_page() || is_singular('page')) {
remove_action( 'genesis_after_header', 'genesis_do_nav', 15 );
    }
}

The 2nd step requires the creation of a new file in your child themes root directory named page_blog.php.

Add the following PHP code at the start of the file and then select the Custom Blog page template from the Page Attributes box on any Edit Page screen.


Comments

One response to “Remove Nav Menu From Front Page & Single Pages Exclude Blog Page”

  1. blogambitions Avatar
    blogambitions

    That worked perfectly, thanks.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.