Support » Plugin: Advance WP Query Search Filter » Order taxonomies in drop down or check box

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author TC.K


    No the plugin does not support this.

    This will required additional work to customize the plugin, which not a ideal way to do this.



    Ok thanks.



    Hey I just saw this and I though I’d help out. What you have to do it edit searchform.php (go to the plugin and then html). You can just insert the HTML using the php echo function.

    First make sure the form id equals the form you want to display the field on.

    Then echo the HTML, you’ll have to put in by hand the meta key you want to compare as well as the keys of the items. Also, depending on how many form elements you have you’ll need to change the ‘3’s that are currently in my form.

    if ($id == Form_Id){
    echo '<div class="awqsf_box cmfdrop-3">
    <label class="taxo-cmf-3">Venue Location</label><br>
    <input type="hidden" name="cmf[3][metakey]" value="meta_key_to_compare">
    <input type="hidden" name="cmf[3][compare]" value="1">
    <select id="cmf-3" name="cmf[3][value]">
    	<option value="wqsfcmfall">All </option>
    	<optgroup label="Fruits">
    	  <option value="Meta_Value_Here"> Banana </option>
    	  <option value="ex. kiwi"> Kiwi </option>
    	<optgroup label="Vegetables">
    	  <option value="Meta_Value_Here">Potato</option>

    If you have any other questions let me know!



    Many thanks itsjaked, I’ll give it a try.

    oh, i was wondering if there is any way to use wordpress tags, or similar, to automatically get the name of the taxonomies by their ID in the case that someday i change them, something like ‘get_the_title($ID);’



    Hi again,

    At the end i opted for a checkbox type form, and following itsjaked’s example and pluging code i used something like this

    ‘<div class=”awqsf_box taxocheck-2″>
    <label class=”taxo-label-2″>Sector</label>
    <input type=”hidden” name=”taxo[2][name]” value=”sector”>
    <label class=”taxcheckbox”><input type=”checkbox” id=”taxo-2″ name=”taxo[2][call]” class=”checkall” >Todos los sectores</label>
    <label class=”taxcheckbox”><input type=”checkbox” id=”taxo-2″ name=”taxo[2][term][]” value=”gimnasios” >Gimnasios</label>
    <label class=”taxcheckbox”><input type=”checkbox” id=”taxo-2″ name=”taxo[2][term][]” value=”salud-belleza” >Todos</label>
    <div style=”clear:both”></div>

    I’ve got some questions,

    How can i get all the terms from the taxonomy in an automatic way and for each term put a label?

    How can i get the name of the term using its ID? so i can use as ‘<label> term </label>’

    The defined classes for labels, etc. are only for style purposes? i want to know if i can get rid of it to make it easier

    Thanks, and sorry for the bad english

    I had the same issues with checkboxes. Needed hierarchical taxonomy checkboxes, so edited taxcheckbox.php and replaced the foreach loop with this:

    $parents = array();
    $children = array();
    foreach($terms as $term){
    	if($term->parent == 0){
    		$parents[] = $term;
    			$children[$term->parent] = array();
    		$children[$term->parent][] = $term;
    foreach($parents as $parent){
    		if(is_array($_GET['taxo'][$c]['term']) ){
    			$selected = (isset($_GET['taxo'][$c]['term']) && in_array($parent->slug, $_GET['taxo'][$c]['term'])) ? 'checked="checked"' : '';}
    			$selected = (isset($_GET['taxo']) && $_GET['taxo'][$c]['term']==$parent->slug) ? 'checked="checked"' : '';
    	$value = $parent->slug;
    	echo '<label class="taxcheckbox"><input type="checkbox" id="taxo-'.$c.'" name="taxo['.$c.'][term][]" value="'.$value.'" '.$selected.'>'.$parent->name.'</label>';
    		echo '<ul class="taxcheck-children">';
    		foreach($children[$parent->term_id] as $child){
    				if(is_array($_GET['taxo'][$c]['term']) ){
    					$selected = (isset($_GET['taxo'][$c]['term']) && in_array($child->slug, $_GET['taxo'][$c]['term'])) ? 'checked="checked"' : '';}
    					$selected = (isset($_GET['taxo']) && $_GET['taxo'][$c]['term']==$child->slug) ? 'checked="checked"' : '';
    			$value = $child->slug;
    			echo '<li><label class="taxcheckbox"><input type="checkbox" id="taxo-'.$c.'" name="taxo['.$c.'][term][]" value="'.$value.'" '.$selected.'>'.$child->name.'</label></li>';
    		echo '</ul>';
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Order taxonomies in drop down or check box’ is closed to new replies.