WordPress.org

Ready to get started?Download WordPress

Forums

Ajax WP Query Search Filter
Multiple Select as Display Type (4 posts)

  1. Aldo
    Member
    Posted 9 months ago #

    Hello

    Would it be possible to add a Multiple Select as display type for taxonomies, and so on to optimize the search form size with large selection options?

    Thanks!
    Aldo

    http://wordpress.org/plugins/ajax-wp-query-search-filter/

  2. TC.K
    Member
    Plugin Author

    Posted 9 months ago #

    Yes, you can. You can change your checkbox in order to do this. There is a filter for this: ajwpqs_tax_field_checkbox()

    eg

    add_filter('ajwpqs_tax_field_checkbox', 'custom_checkbox_field','',9);
    function test_field_5($html,$type,$exc,$hide,$taxname,$taxlabel,$taxall,$c,$divclass){
    	//here you can customize your checkboxes.
    
    }

    Frankly, it is not easy to use this filter, if you are not familiar with those parameters, you can refer to /classes/ajwpqsf-misc-class.php and look for function output_formtaxo_fields to see how to use it.

  3. Aldo
    Member
    Posted 9 months ago #

    Thanks, worked perfectly.
    Maybe as Feature request if you would add multiselect as possible display type, would be great ;-)

  4. Aldo
    Member
    Posted 8 months ago #

    Hello

    Just realized, that my code does not the job as the checkboxes.

    I use this code to create a multiselect list:

    add_filter('ajwpqs_tax_field_checkbox', 'custom_checkbox_field','',9);
    function custom_checkbox_field($html,$type,$exc,$hide,$taxname,$taxlabel,$taxall,$c,$divclass){
    	//here you can customize your checkboxes.
    	$eid = explode(",", $exc);
    		$args = array('hide_empty'=>$hide,'exclude'=>$eid );
            $terms = get_terms($taxname,$args);
    		$html  = '<div class="'.$divclass.' taxdropdown-'.$c.'"><label class="tax-label-'.$c.'">'.$taxlabel.'</label>';
    		$html .= '<input  type="hidden" name="taxo['.$c.'][name]" value="'.$taxname.'">';
    		$html .=  '<select id="taxselect-'.$c.'" name="taxo['.$c.'][term]" multiple class="chosen chzn-select"><option selected value="awpqsftaxoall">'.$taxall.'</option>'; 
    
    					foreach ( $terms as $term ) {
    						$html .= '<option value="'.$term->slug.'">'.$term->name.'</option>';
    					}
    				$html .= '</select><br>';
    				$html .= '</div>';
    
    				return $html;
    
    }

    Unfortunately the first selection gets only to the search query. What else is needed, so your code picks up all the selected terms in the multiselect list?

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.