php - Multiple Taxonomy Dynamic Search -


i've on wordpress site search include multiple (three) taxonomy. searching working i'm looking issue hide empty categories

taxonomy 1: brand

taxonomy 2: model

taxonomy 3: version

i'm looking possible after choose "brand" in model dropdown list category posts include choosen "brand".

and similat. in "version" dropdown list categories witch include "brand" , "model".

brand

  • vw
  • audi

model

  • golf
  • a4

version

  • 1.9tdi
  • 2.0 tsfi

now dropdowns list including full list of taxonomy, want filter similar/post same taxonomy.

like

  1. first dropdown lilt - choose audi
  2. search posts taxonomy "audi" , return categories taxonomy "model" second dropdown
  3. sedond dropdown list - choose a3
  4. search posts taxonomy "a3" , return categories taxonomy "model" third dropdown
  5. run search

<?php  global $theme_search_fields;  if( !empty($theme_search_fields) ):  ?>  <div class="as-form-wrap">      <form class="advance-search-form clearfix" action="<?php global $theme_search_url; echo $theme_search_url; ?>" method="get">                 <div class="option-bar large">              <label for="select-location"><?php _e('marka', 'framework'); ?></label>              <span class="selectwrap">                  <select name="location" id="select-location" class="search-select">                      <?php advance_search_options('property-city'); ?>                  </select>              </span>          </div>                    <div class="option-bar large">              <label for="select-status"><?php _e('model', 'framework'); ?></label>              <span class="selectwrap">                  <select name="status" id="select-status" class="search-select">                      <?php advance_search_options('property-status'); ?>                  </select>              </span>          </div>                    <div class="option-bar large">              <label for="select-property-type"><?php _e('wersja', 'framework'); ?></label>              <span class="selectwrap">                  <select name="type" id="select-property-type" class="search-select">                      <?php advance_search_options('property-type'); ?>                  </select>              </span>          </div>                <div class="option-bar">          <input type="submit" value="<?php _e('wyszukaj', 'framework'); ?>" class=" real-btn btn">      </div>              </form>  </div>  <?php  endif;  ?>

thank help.

you can use tax query search result mentioned below, can customize according code . hope can using hide empty category.

        $args = array(             'post_type' => 'post',             'tax_query' => array(                 'relation' => 'and',                 array(                     'taxonomy' => 'movie_genre',                     'field'    => 'slug',                     'terms'    => array( 'action', 'comedy' ),                 ),                 array(                     'taxonomy' => 'actor',                     'field'    => 'term_id',                     'terms'    => array( 103, 115, 206 ),                     'operator' => 'not in',                 ),             ),         );         $query = new wp_query( $args );  

and showing hide empty categories please try :

     $categories = get_terms( 'category', array(         'orderby'    => 'count',         'hide_empty' => 0,      ) ); 

i hope other can revert me. suggestions welcome.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -