Title: Conditional logic
Last modified: August 24, 2016

---

# Conditional logic

 *  Resolved [Jon Schroeder](https://wordpress.org/support/users/jonschr/)
 * (@jonschr)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/conditional-logic-13/)
 * I’m wondering if you have a methodology where I could use conditional logic to
   hide/display a filter based on the entry in a previous filter.
 * So on this page: [http://sqrft.flywheelsites.com/jobs/](http://sqrft.flywheelsites.com/jobs/)
 * I’d like to hide “trades” by default, then if a particular industry is selected,
   I’d like to show “trades.”
 * Any thoughts on how I could best proceed?
 * [https://wordpress.org/plugins/beautiful-taxonomy-filters/](https://wordpress.org/plugins/beautiful-taxonomy-filters/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Thread Starter [Jon Schroeder](https://wordpress.org/support/users/jonschr/)
 * (@jonschr)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/conditional-logic-13/#post-6147661)
 * Please note that I _am_ using the select2 library; if I were just using the standard
   controls, this would be a simple jQuery script to detect the state of the select
   box, then hide/show things accordingly, but it looks a step or two more complex
   when using that library.
 *  Plugin Author [Jonathandejong](https://wordpress.org/support/users/jonathandejong/)
 * (@jonathandejong)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/conditional-logic-13/#post-6147802)
 * Hi Jon,
 * I started out thinking trades was a term not a tax so had to rewrite this now..
   hah.
 * So here’s how I’d do it as simple as possible. You could spruce it up a bit by
   using CSS classes and css3 animations/transitions for showing hiding instead 
   if you’d like
 * * Hide trades with css `#beautiful-taxonomy-filters-tax-job-name{ display:none;}`
   *
   Check for the value being set in the job categories and if it’s blue collar just
   show the whole thing.
 *     ```
       jQuery('#select-job-industry')on("change", function (e) {
       var val = jQuery(this).val();
       if(val === 'artisans'){ //show bluecollar, hide whitecollar
       jQuery('#beautiful-taxonomy-filters-tax-job-name').slideDown();
       jQuery('#beautiful-taxonomy-filters-tax-job-categories').slideUp();
       }else{ //and vise versa
       jQuery('#beautiful-taxonomy-filters-tax-job-name').slideUp();
       jQuery('#beautiful-taxonomy-filters-tax-job-categories').slideDown();
       }
       });
       ```
   
 *  Thread Starter [Jon Schroeder](https://wordpress.org/support/users/jonschr/)
 * (@jonschr)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/conditional-logic-13/#post-6147819)
 * Wow, this is a much more specific answer than I was expecting. I’ll play around
   with that and see if I can get that to work.
 * Much appreciated, and great work – this is massively better than every other 
   filter system for taxonomies I could find. My only feature request would be the
   ability to do multi-select, but that’s probably not a simple feature to add.
 *  Plugin Author [Jonathandejong](https://wordpress.org/support/users/jonathandejong/)
 * (@jonathandejong)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/conditional-logic-13/#post-6147821)
 * Do so 🙂 I think it should work but I haven’t checked it for spelling errors 
   etc.
 * Thank you! I couldn’t find anything good either, hence this plugin spawned 😉
   Please leave a review if you like. It really helps me out.
 *  Thread Starter [Jon Schroeder](https://wordpress.org/support/users/jonschr/)
 * (@jonschr)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/conditional-logic-13/#post-6147827)
 * That’s OK, I needed some help getting started is all.
 * Here’s the code ultimately used, since it might come in handy for someone else
   someday:
    [https://gist.github.com/redblueconcepts/6bc52166db037e880772](https://gist.github.com/redblueconcepts/6bc52166db037e880772)
 * This corrects for a few issues I found in actually implementing it:
    * A user
   could make a selection on a conditional field, then hide it. This resets both
   the field and the select when the field which is the source of the conditional
   is changed to avoid accidental criteria being added to the search * Conditional
   fields are hidden by default, then only shown when the selection is made
 *  Plugin Author [Jonathandejong](https://wordpress.org/support/users/jonathandejong/)
 * (@jonathandejong)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/conditional-logic-13/#post-6147830)
 * Cool! Much better than my hasty directly-in-commentfield hacking 🙂
 * I’ll mark this topic as solved then!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Conditional logic’ is closed to new replies.

 * ![](https://ps.w.org/beautiful-taxonomy-filters/assets/icon-256x256.png?rev=1654967)
 * [Beautiful taxonomy filters](https://wordpress.org/plugins/beautiful-taxonomy-filters/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/beautiful-taxonomy-filters/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/beautiful-taxonomy-filters/)
 * [Active Topics](https://wordpress.org/support/plugin/beautiful-taxonomy-filters/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/beautiful-taxonomy-filters/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/beautiful-taxonomy-filters/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Jonathandejong](https://wordpress.org/support/users/jonathandejong/)
 * Last activity: [10 years, 12 months ago](https://wordpress.org/support/topic/conditional-logic-13/#post-6147830)
 * Status: resolved