Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>

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

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.

UPDATE

This is an example of a Spanish website that has this functionality.

http://www.infojobs.net/ofertas-trabajo

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.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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

http://wordpress.org/plugins/query-multiple-taxonomies/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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