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,) );    ?>


Which outputs:

<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>

Now I want to add the following functionality:

  1. 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 href).

  2. Once any <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.

  3. 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.

The goal is to let the user filter photos by choosing several taxonomy terms for example Mom and Dad, or Mom, Dad and John. I tried this using checkboxes and it works, but I would like to save the user the annoyance of clicking submit every time she selects a term. Furthermore, I tried using jQuery/JavaScript with cookies to remember the link state but it did not work for more than one link.

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.

1 Answer 1


I haven'f found a solution for this, but instead I found a plugin that does exactly this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.