Custom Menu
-
Using other posts from this forum I have been able to learn how to display a different custom menu in the sidebar of each page and category. Here’s an example of what I’ve done…
<?php
if (is_page(’19’)){
wp_nav_menu(array(‘menu’=>’menu-name-1’, ));
} elseif (is_page(’20’)) {
wp_nav_menu(array(‘menu’=>’menu-name-2’ ));
} elseif (is_page(’21’)) {
wp_nav_menu(array(‘menu’=>’menu-name-3’ ));
}
?>This works fine, but what I would like is not to have to add a new elseif every time I add a page – I’d rather have a collection of page numbers for each menu.
So far, my attempts to do this have failed. I have tried (is_page(’19’, 20′, ’21’)) and (is_page(’19’ || ’20’ || ’21’)) and both of these without quote marks.
I just want my code to look better and be easier to maintain. Any ideas what I could be missing or do I just have to suffer an ever-increasing line of elseifs?
Thanks in advance!
PS Sorry, can’t direct you to my site as it’s not public yet.
- The topic ‘Custom Menu’ is closed to new replies.