Set Custom Menu For Different Pages

The code in this tutorial enables you to display any menu on any page, post, custom post type, custom taxonomy, archive, author, blog, category, search or tag page using any conditional tags.

In this example, the code changes the primary nav menu based on category, which by default, displays after the header.

3 menus have been created named Primary, Financial & Accounting.

The menu named Financial displays on all posts in the Financial category including the category archive page. The menu named Accounting displays on all posts in the Accounting category including the category archive page. The menu named Primary displays on all other pages.

Here’s the demo video showing you exactly how it works.

Demo Video

The video shows how 3 menus have been created on the nav-menus.php admin page which are displayed after the header in the primary menu location based on specific conditions. In this example, a different menu displays based on the category.

The code has been written based on the following question from a member of the Genesis community :

I need to set a primary navigation menu on a per page and CPT basis.

Usage With Custom Post Types

Swap out the conditional tags in the code with the following for usage on single custom post type pages:

is_singular( 'add-cpt-name-here' )

For usage with a custom post type archive :

is_post_type_archive( 'add-cpt-name-here' )

Register or login to access the following code for members:

Related Tutorials

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.