I have a custom post type and I'm trying to call up different variations of the navigation based on the custom taxonomy slug. I've done this fairly easily with normal posts, like so:
<?php
if ( is_category( 'mixers' )) {
include (TEMPLATEPATH.'/nav-mixers.php');
} elseif ( is_category( 'monitors' )) {
include (TEMPLATEPATH.'/nav-monitors.php' );
} elseif ( is_category( 'speakers' )) {
include (TEMPLATEPATH.'nav-speakers.php');
}
?>
however this is proving challenging for a custom post type. I feel like I'm close but I need some help now. Here's where I currently am.
<?php
$terms = get_the_terms( $post->id, 'prodcat' ); // get an array of all the terms as objects.
$terms_slugs = array();
foreach( $terms as $term ) {
$terms_slugs[] = $term->slug; // save the slugs in an array
}
if( $terms ) :
get_template_part( 'nav', slug );
else :
get_template_part( 'nav', 'home' );
endif;
?>
Any help is much appreciated!
get_template_part( 'nav', slug );
is already missing the$
for the variable. Would you mind adding a link to the original source here in the comments or as edit to the question?