The Genesis Framework includes a primary and a secondary navigation (or nav), which are the two main menu bars that usually display between the site header and the main content area.
Your Genesis child theme has the power to register more nav menu locations and/or unregister one or both of the built in locations. This can happen across the whole site or just under some circumstances, such as a stripped down landing page template.
Genesis provides an easy way to check if any given nav menu location is currently supported.
The function to use is
genesis_nav_menu_supported. This is a boolean function that returns true or false based on whether the child theme supports a given nav menu location.
The basic usage of the function
genesis_nav_menu_supported is below. Just replace
your_desired_hook with your desired hook,
ID with the ID of the menu location you are checking for and place your code in the indicated location.
This function accepts a single argument, which is the ID of the menu location to check for (not the ‘friendly’ name). The IDs of the two built in menu locations are
This function returns:
- true if the menu location is supported
- false if the menu location is not supported
- false if the child theme does not support
There are no filters on the output of this function.
Example 1: check if the footer nav location is supported before adding a skip link for it. This assumes the footer nav has an ID attribute of
genesis-nav-footer for the skip link to work.
genesis_nav_menu_supported has been included since version 1.8.0.
genesis_nav_menu_supported is located in lib/functions/menu.php.