• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Logo

CITROWEB

First choice for your online presence

  • home page
  • Services
    • Web design, web development and consulting
    • Online stores with WooCommerce
    • Technical support for WooCommerce stores
    • Search engine marketing
      • SEO: Your website receives more relevant visitors
      • SEA: Search engine advertising for your website
    • Web hosting packages and domains
  • Blog
  • Contact us
Home » Blog » Remove navigation menu from a page in Genesis themes

Remove navigation menu from a page in Genesis themes

19. March 2022

There are several ways to remove or hide your primary and secondary navigation menus using the Genesis framework in WordPress.

The easy way is to hook into the execution via an action and remove the action responsible for the menu. To prevent the navigation menus from disappearing on all pages, a check is made beforehand to determine on which page the execution is currently taking place.

Remove primary navigation menu from home page

add_action('get_header', 'cw_child_remove_genesis_do_nav');
function cw_child_remove_genesis_do_nav() {
   if (is_home()) {
      remove_action('genesis_before_header', 'genesis_do_nav');
   }
}

If the primary navigation menu is included after the header, instead of genesis_before_header, genesis_after_header is used with remove_action (code line 4).

Sometimes it is also necessary to specify a priority parameter, as in the case of the genesis-sample-theme, if the action was registered with a priority. Line 4 then looks like this:

remove_action('genesis_header', 'genesis_do_nav', 12);

And already it works with the sample theme from Genesis.

Remove secondary navigation menu from home page

add_action('get_header', 'cw_child_remove_genesis_do_subnav');
function cw_child_remove_genesis_do_subnav() {
   if (is_home()) {
      remove_action('genesis_after_header', 'genesis_do_subnav');
   }
}

Remove primary navigation menu from a specific page

First, the ID of the page or post must be known. You can see them in the URL of the edit dialog of the page.

Edit URL page

The code to remove the main menu from the page with ID 7 looks like this:

function cw_remove_genesis_do_nav() {
   if (is_page(7) ) {
      remove_action('genesis_after_header', 'genesis_do_nav');
   }
}
add_action('get_header', 'cw_remove_genesis_do_nav');

Filed Under: Genesis Framework

Primary Sidebar

Search

Recent Posts

  • Remove “Thank you for your trust in WordPress” from the bottom of the dashboard
  • Remove WordPress logo from toolbar
  • Change login cookie lifetime in WordPress
  • WordPress multisite and cookie settings in wp-config.php
  • Update GUIDs in WordPress after domain move

Footer

Logo




© 2023 CITROWEB
  • Data protection
  • imprint
  • Deutsch