So I have a list of users within a list of taxonomies in a sidebar. I need to be able to have the list of users stay open (they are closed by default and open on click) if the current page is a user page. So for a user within taxonomy A, on that users page the list of users for taxonomy A would be open by default. Basically, I need to create a context awareness similar to how WordPress does with menus.
Here is the loop that creates the list:
<div class="sidebar sidebar-people">
<div class="menu-people-menu-container">
<?php $disciplines = get_terms('disciplines');
echo "<ul id='menu-people-menu' class='menu'>";
foreach($disciplines as $discipline) {
$params = array('limit' => -1,'where' => 'user_discipline.term_id = ' . (int) $discipline->term_id. '');
$mypod = pods( 'user', $params );
if ( 0 < $mypod->total() ) {
echo '<li><a href="#">' . $discipline->name . '</a>';
$users = get_users('meta_value='. $discipline->term_id .'');
if(count($users)>0) {
echo '<ul class="sub-menu postid-'. get_the_id() .'">';
foreach( $users as $user ){
echo '<li><a href="'. home_url(mb_strtolower('/culture/our-people/'. $user->user_firstname .'-'. $user->user_lastname) ). '">' . $user->user_firstname .' '. $user->user_lastname . '</a></li>';
}
} else {
echo '<li><a href="#">No results found</a></li>';
}
echo '</ul></a></li>';
}
}
echo "</ul>";
?>
</div>
</div>
And here's the JS that opens and closes it:
//Sidebar Menu SLide Toggles
$("#menu-people-menu").on("click", "> li > a", function (e) {
e.preventDefault();
$("#menu-people-menu").find(".sub-menu").hide();
$(this).closest("li").find(".sub-menu").first().fadeToggle("slow");
});
How do I go about keeping taxonomy a open when on the user 1 page dynamically?
Taxonomy A -user 1 -user 2 -user 3 Taxonomy B -user 4 -user 5 -user 6 Taxonomy C -user 7 -user 8 -user 9