Custom menus, widgets and conditional statements
-
I’m employing custom widgets for my client because it’s easy and they have several menus they need to create specific to site sections. I then want to allow them to add to the custom menu dynamically using widgets (I create the spaces needed for the widget and they drag and drop the menus into that widget bucket).
I tried using the following code but when the left nav sidebar is supposed to load, the page stops loading.
[Code moderated as per the Forum Rules. Please use the pastebin]
The custom menus need to show up on all child pages (but not the parent page because that uses a different layout). What am I doing wrong with the above?
I got this to work:
if (is_page( 'sport-fitness' ) || '269' == $post->post_parent){ //menu for Sport & Fitness pages wp_nav_menu( array('menu' => 'sport-fitness' )); }elseif(is_page( 'eat-smart' ) || '118' == $post->post_parent){ //menu for Eat Smart pages wp_nav_menu( array('menu' => 'eat-smart' )); }else{ //default menu }
But then I’m stuck without the headers that the widgets provide (which they want). For example:
SPORT & FITNESS<ul> <li>Home</li> <li>Link 1 </li> <li>Link 2</li> <li>Link 3</li> </ul>
Help would be greatly appreciated. I’ve been trying to figure this out for a couple days now and it’s a blocker to finishing their site.
TIA!
- The topic ‘Custom menus, widgets and conditional statements’ is closed to new replies.