My site has a blog component as well as an extensive collection of static pages (nearly 300).
I currently have a hand-coded drop down menu showing selected pages in my top-of-page navigation menu.
I created this as a work-around since my theme (Prosense) does not have native support for menus and my attempts at adding native support were unsuccessful.
I’m ready for a new theme and am now trying out different ones, but when I select “preview” every single page on my site (nearly 300) appears in the menu.
For example, this is the case with 2011, atahualpa, and other themes I’ve tried.
I have not assigned any “parent” attributes to any pages, and I do not wish to designate subpages and end up with a huge “cascading” menu of pages and subpages.
I just want to have 15-20 selected pages in my menu as standalone links.
What do I need to do so that when I try out new themes (and make the switch) only the selected pages appear in the menu?
My site is here
Any advice would be most appreciated.
Most themes support wp_nav_menu which allows you to create a menu from within the appearance->menus tab. You can add and arrange menu items as you see fit
Yes, but my current theme does not.
What I’d like to do is make any necessary adjustments now so that when I upgrade to a new theme, I don’t have all 300 pages in the menu upon launch.
Any idea on how to do that?
I believe you could add something like
register_nav_menu( 'primary', __( 'Primary Menu' ) );
to your functions.php in your existing theme. This wouldn’t change any display or anything, but it would enable the ability to create a menu.
Then you could set the menu up before switching.
I haven’t ever had to do this….but it makes sense in my mind that this would work
So far so good. I’m going to build the menu and then try previewing another theme to see what happens…
Well, I created a menu, and added it to my website as a sidebar widget (the only option).
But when I preview a new theme, I still get all 300 pages showing in the top menu
Yeah, it would only be available as a widget unless you put more code in the theme.
I just wanted to get you the interface to create the menu.
I guess I don’t know if you would be able to have the theme preview not display all your pages. It looks like you have to actually activate a theme and the assign your menu…..
Hmm, well it looks like my only option then is to put my site in maintenance mode during the switch for as long it takes to tweak all the options….something I was hoping to avoid.
register_nav_menu( 'primary', 'Primary Menu' );
__()seems a bit unnecessary since there’s no need for translating that string. Using this in the theme’s
functions.phpwill enable that menu. But, you then need to use this where you want the menu to actually show (
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
By default, this falls back to
wp_page_menu()which will display all your pages. Go to
Appearance->Menusto actually create a new custom menu to replace your massive default menu.
Also, Twenty Eleven and Atahualpa (I think) already support custom menus. Shouldn’t have to do any code stuffs; Just activate the theme, create the custom menu, and you’re good to go.
@big Bagel, it was a c/p from twentyeleven, forgot to remove the translation bit after removing the domain, no harm no foul….
Thanks, I will have a look through the doc and try this again.
@rev. Voodoo: Indeed; doesn’t hurt anything to leave it in there. I also copy/pasted from Twenty Eleven. 🙂
Big Bagel, I followed your instructions and inserted
register_nav_menu( ‘primary’, ‘Primary Menu’ ); in the theme functions file
Then created a custom menu called “Primary Menu”
And added this in the header: <?php wp_nav_menu( array( ‘theme_location’ => ‘Primary Menu’ ) ); ?>
Still, every single one of my pages showed up in the menu!
I must be doing something wrong. Or maybe there’s something weird about my current theme.
- The topic ‘How to control which pages appear in menu’ is closed to new replies.