I am sure this has been asked. It's new territory for me so I don't have the full vocabulary of what I'm doing, nor am I sure this is the right way to do it.
I've got a bunch of internal pages on a site that the only real change from page to page is the tertiary nav I've got in a sidebar div. (And obviously the main content area).
I've got a bunch of theme_locations setup for wp_nav_menu. What's the best way to display them based on page ID or parent ID or something like that?
Something along these lines I found, but it's not quite what I need:
<?php
$thispageid = get_the_ID();
if( $thispageid == "1" ) )
wp_nav_menu( array( 'theme_location' => 'tertiary_surgeons_consulting' ) );
if( $thispageid == "2" ) )
wp_nav_menu( array( 'theme_location' => 'tertiary_surgeons_consulting' ) );
else
wp_nav_menu( array( 'theme_location' => 'tertiary_surgeons_education' ) );
?>
Is this thought process the right way to accomplish this, or am I missing some other way that's already in WordPress?
is_page()
? It takes arrays too for multiple pages:if( is_page( array(1,2) ) )
, orif( $post->ID == 1 )
– deflime Apr 10 '15 at 21:11