I have a photo gallery with wp_tag_cloud in the sidebar to display hierarchical taxonomies that categorize photos. The taxonomy name is person.
<div id="filter"> <?php wp_tag_cloud( array( 'taxonomy' => array ('person') , 'format' => 'flat' , 'separator' => " | ", 'smallest' => 20, 'largest' => 20,'unit' => 'px', 'number' => 0, 'orderby' => term_id, 'order' => 'DESC', 'link' => 'view', 'echo' => 1,) ); ?> </div>
<div id="filter"> <a href="#" class="tag-link-23" title="type 1" style="font-size: 20px;">Steven</a> | <a href="#" class="tag-link-24" title="type 2" style="font-size: 20px;">John</a> | <a href="#" class="tag-link-30" title="type 3" style="font-size: 20px;">Mom</a> | <a href="#" class="tag-link-26" title="type 4" style="font-size: 20px;">Dad</a> | <a href="#" title=" type 5" style="font-size: 20px;">Grandpa</a> </div>
Now I want to add the following functionality:
If the user clicks on Steven, if
<a>has not the class="selected", then add it. Else, if
<a>has class="selected" remove it and return false (do not go to
<a>is selected, if the user selects another
<a>(e.g. Mom), then go to that page and keep Steven "selected" and add class="selected" to Mom--do so for any other terms.
Every time a link is clicked, if it's not the first time, add "+" and the name of the term (e.g.
example.com/?person=steven+mom) in the URL, so that wordpress retrieves posts under both terms.
Anything would be helpful since I haven't been able to find anything similar to this on Google.
This is an example of a Spanish website that has this functionality.
If you click on different checkboxes on the left sidebar you can categorize the content. You can sort content by choosing multiple terms and it loads the content right after you check a checkbox.