Category/Taxonomy Navigation
$taxonomy = 'products-category';
$term = get_queried_object();
$current_term_id = $term->term_id;
<?php foreach ($parent_terms as $parent_term) : ?>
$active = ($term->slug == $parent_term->slug) ? 'open' : '';
$active2 = (term_is_ancestor_of($parent_term->term_id, $current_term_id, $taxonomy)) ? 'open' : '';
<?php endforeach; ?>
<?php
$taxonomy = 'team-category';
$terms = $wp_query->get_queried_object();
if ($terms->parent == 0) {
$parent_id = $terms->term_id;
} else {
$parent_id = $terms->parent;
}
$parent_terms = get_terms( array(
'taxonomy' => $taxonomy,
'hide_empty' => true,
'parent' => $parent_id
) );
?>
<div class="team-category-nav">
<h2 class="title">
<?php single_cat_title(); ?>
</h2>
<a href="<?php echo get_term_link($terms); ?>">
<?php _e('All Staff', 'html5blank'); ?>
</a>
<?php foreach ($parent_terms as $parent_term) : ?>
<?php $class = (get_queried_object()->slug == $parent_term->slug) ? 'current' : ''; ?>
<a class="<?php echo $class; ?>" href="<?php echo get_term_link($parent_term); ?>">
<?php echo $parent_term->name; ?>
</a>
<?php endforeach; ?>
<?php wp_reset_query(); ?>
</div>
<?php
$taxonomy = 'projects';
$term = get_queried_object();
$term_id = $term->term_id;
if ($term->parent == 0) {
$parent_id = $term->term_id;
} else {
$parent_id = $term->parent;
}
$terms_parents = get_terms( array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
'parent' => 0
) );
?>
<aside class="sidebar" role="complementary">
<div class="widget">
<ul class="menu">
<li>
<a href="<?php bloginfo('url'); ?>/projects/">
<?php _e('Overview', 'html5blank'); ?>
</a>
</li>
<?php foreach ($terms_parents as $terms_parent) : ?>
<?php
$terms_childs = get_terms( array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
'parent' => $terms_parent->term_id
) );
$active = ($parent_id == $terms_parent->term_id) ? 'active' : '';
?>
<li>
<a class="btn-menu icon-after grey arrow-right <?php echo $active; ?>" href="<?php echo esc_attr(get_term_link($terms_parent, $taxonomy)); ?>">
<?php echo $terms_parent->name; ?>
</a>
<?php if($terms_childs) : ?>
<ul class="sub-menu <?php echo $active; ?>">
<?php foreach ($terms_childs as $terms_child) : ?>
<?php $active2 = ($term_id == $terms_child->term_id) ? 'active' : ''; ?>
<li>
<a class="<?php echo $active2; echo $class; ?>" href="<?php echo esc_attr(get_term_link($terms_child, $taxonomy)); ?>">
<?php echo $terms_child->name; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php wp_reset_query(); ?>
</ul>
</div>
</aside>