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

    (@wp_dummy)

    Well, you need to customize it by using this filter:
    uwpqsf_tax_field_dropdown (assume it is taxonomy filter that you meant).

    Refer to this source code how to use the filter. Assuming you know how to code ,though.

    Here’s what I did – it works great functionally, but it is triggering an error I am trying to fix. Not sure if the answer is in this source code, so checking still.

    My dropdowns were for meta fields. All I did was add a “|” at the top of the list, which then created a blank line without an actual field at the top of the dropdowns.

    When I tested it, it triggered an error for the blank field, but the dropdown boxes still functioned, and they returned the correct search results.

    The error I received was:”Notice: Undefined offset: 1 in /home/content/28/9910428/html/staging-db/wp-content/plugins/ultimate-wp-query-search-filter/classes/uwpqsf-front-class.php on line 94″

    So I am going to check to see if the code for taxonomies allows me to override this error message, in which case, it is the easiest fix, and this plugin becomes the perfect solution for filtering ACF fields.

    TC.K, thanks for your work on this plugin, and if you already know the easy to way to make this work, I’d appreciate any tips!

    Thread Starter maxgx

    (@maxgx)

    here’s what i added to functions.php

    
    add_filter('uwpqsf_tax_field_dropdown','custom_dropdown_output','',12);
    function custom_dropdown_output($html,$type,$exc,$hide,$taxname,$taxlabel,$taxall,$opt,$c,$defaultclass,$formid,$divclass){
    	$args = array('hide_empty'=>$hide,'exclude'=>$eid );
    	$taxoargs = apply_filters('uwpqsf_taxonomy_arg',$args,$taxname,$formid);
    	$terms = get_terms($taxname,$taxoargs); $count = count($terms);
    	if($type == 'dropdown'){
    		$html  = '<div class="'.$defaultclass.' '.$divclass.'" id="tax-select-'.$c.'"><span class="taxolabel-'.$c.'">'.$taxlabel.'</span>';
    		$html .= '<input  type="hidden" name="taxo['.$c.'][name]" value="'.$taxname.'">';
    		$html .= '<input  type="hidden" name="taxo['.$c.'][opt]" value="'.$opt.'">';
    		$html .=  '<select id="tdp-'.$c.'" class="tdp-class-'.$c.'" name="taxo['.$c.'][term]">';
    		$html .=  '<option selected value="">-</option>';
    		if(!empty($taxall)){
    			$html .= '<option selected value="uwpqsftaxoall">'.$taxall.'</option>';
    		}
    		if ( $count > 0 ){
    			foreach ( $terms as $term ) {
    				$selected = (isset($_GET['taxo'][$c]['term']) && $_GET['taxo'][$c]['term'] == $term->slug) ? 'selected="selected"' : ''; 							
    				$html .= '<option value="'.$term->slug.'" '.$selected.'>'.$term->name.'</option>';
    			}
    		}				
    		$html .= '</select>';
    		$html .= '</div>';
    		return  apply_filters( 'custom_dropdown_output', $html,$type,$exc,$hide,$taxname,$taxlabel,$taxall,$opt,$c,$defaultclass,$formid,$divclass);
    	}
    }
    

    it’s the same output found in uwpqsf-front-class.php with the addition of the empty option.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘add first empty option to dropdown’ is closed to new replies.