Instead of using sidebar widgets to tell on what page they should be visible, I like to choose at the menu settings to appear on specific pages.

Default Wordpress way:

How it looks default

So projects is a page and has some subpages. But what if I have like 10 more of these pages and subpages with the same situation.

I would like to add an extra setting (a list of the top level pages):

Where I want the setting

But I cannot find any documentation, actions, filters etc when these settings are loaded.

  • 1
    I think it depends on your theme. But as a starting point codex.wordpress.org/Navigation_Menus should help!! – sri Jun 20 '14 at 8:00
  • 1
    I seen that link a lot of times, there is no information about adding settings to a menu. Only create and display a custom menu... – user40422 Jun 20 '14 at 8:01
  • Ouch. I think that is a native Joomla option, apparently not in WordPress. For your site, you could create custom output category/pages.php files and then add a unique custom menu there but that is a total pain in the neck. You'd have four output .php pages and four unique menus, one for each selection above. One easy way to implement is to use sidebar widgets as your primary navigation tool. the custom menu widget tool is pretty simple. Create a menu for each page, assuming you have unique templates for each. Note, sidebar is not the best word. You can put a widget anywhere. – zipzit Jun 20 '14 at 8:10
  • I am aware of the sidebars and widgets. These small website parts that are also not connected to a page. I don't want to use sidebars and widgets and have disabled them because I don't use any of them. Anyway, I think the menu locations are settings of the menu, not a setting of a widget which contains a menu. – user40422 Jun 20 '14 at 8:23
  • Is your question just "How do I add custom menu settings?" or is it also "How do I use custom menu settings to display a menu on certain pages only?"? – engelen Jun 20 '14 at 12:47

That's a nice option, but I agree with sri, right now it really depends on your theme. You can do a work-around through is_page(). You need to write something like this on your page.php theme file:

    if (is_page('projects')) {
        if ( is_active_sidebar( 'sidebar-navigation' )) {
            dynamic_sidebar( 'sidebar-navigation' );

If you want to show the sidebar on other pages as well, you can use logic or like this:

if (is_page('projects') || is_page('home') || is_page('post-page'))
  • I don't know of a better solution, but this is really bad practice in the coding world. I'm thinking that at the very least maybe loop through an array or something then perform menu swap. Definitely appreciate the answer though. Sigh – BRogers Feb 4 '16 at 6:55

This is how you can do it in Twenty Twelve themes header.php copied to a child theme.

<?php if ( is_page('projects') ) : ?>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu' => 'conditional-menu-name', 'menu_class' => 'nav-menu' ) ); ?>
<?php else : ?>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu' => 'Primary', 'menu_class' => 'nav-menu' ) ); ?>
<?php endif; ?>

Create a new menu with the items you want to display and swap out the conditional-menu-name in the above code with the name of your menu.

menu_class names may need changing for themes other than Twenty Twelve.



I think using a plugin for this is better, so you can keep the functionality even if you change themes in the future. Check out this plugin. It does what you want, but slightly differently than how you mocked it up.


If this helps, please up vote or accept as the answer. Thanks!

  • I have tried this plugin. With this plugin, you can only select a menu for a specific post type. I want to select the menu for each page. – user40422 Jul 15 '14 at 6:33
  • If you only have one menu across the site, and you just want to hide certain links in that menu when a user is on a certain page, this plugin does that. After you select the post type you want the menu on (page is what you want, or more) then go to edit a page, and you can check the links you want hidden. This other one does it the opposite way. You select a menu from a metabox on the edit page screen, so you need multiple menus to choose from: wordpress.org/plugins/ce-wp-menu-per-page – Mark.C Jul 15 '14 at 19:46

I know this thread is old but in case someone would need search for answer for this, I would like to suggest the conditional menus from themify https://themify.me/conditional-menus. You choose which menu to use, per page, category, meta, everything. and it is free :) hope this helps


If you are willing to re-engage your widgets and want a simple solution, you can use a plugin called Display Widgets. I have used this and use the text portion where you can add links to where you want to go. It works whether the links are on you own site or to another site. It has a space down below the text where you can choose which pages to show or hide. You can still remove the widgets that you do not use.

I played around with the menus for quite a while before I looked for and found this plugin. It works well.

You can find it in the Plugins section of WordPress.org.

  • Thank you very much! But I am not looking for an extra plugin. And I don't use widgets since these floating website parts are too hard to understand for some of my customers. – user40422 Jun 20 '14 at 14:19

One option would be to make custom templates for each menu that you have. (That refers to the theme locations check box) Then on every page, you choose the template that you want it to use and it will also use the menu associated with that template.


It gives you the same result I think you are looking for but rather than telling each menu what page it shows on, you will be telling each page what menu will show on it. An added benefit of doing it this way is that there is no way for you to accidentally tell two menus to be in the same place at the same time.

  • Yes, I have looked at this. But the developer never knows how many menus the user needs. So I have to create a lot of templates to cover them all. template_a.php, template_b.php, template_c.php etc. – user40422 Jul 24 '14 at 6:45

You can use Menu Swapper plugin for doing same thing from admin panel. Here is the Demo of this plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy