• I’m having an issue where my search results are containing ANY ONE of the search parameters I’m using rather than ALL of the parameters I’ve selected via checkbox. For example, if I’m trying to search something that fits both the category “white” and the category “cloth,” my search results are of items that are are white and cloth or white or cloth. From the choice below, I have selected: “AND”

    Boolean relationship between the taxonomy queries
    ANDOR
    AND – Must meet all taxonomy search.
    OR – Either one of the taxonomy search is meet.

    https://www.ads-software.com/plugins/ajax-wp-query-search-filter/

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

    (@wp_dummy)

    You can try to use ajwpqsf_get_taxo() filter hook.

    add_filter('ajwpqsf_get_taxo', 'custom_checkbox_query','',3);
    function custom_checkbox_query($taxo,$id, $gettaxo){
      $taxo ='';
      global $wp_query;
      $options = get_post_meta($id, 'ajaxwpqsf-relbool', true);
      $taxrel = isset($options[0]['tax']) ? $options[0]['tax'] : 'AND';
    	if(!empty($gettaxo)){
              $taxo=array('relation' => $taxrel,'');
    	   foreach($gettaxo as  $v){
    		 if(!empty($v['term']))	{
    	  	  if( $v['term'] == 'awpqsftaxoall'){
    			 $taxo[] = array(
    			 'taxonomy' => strip_tags( stripslashes($v['name'])),
    			'field' => 'slug',
    			'terms' => strip_tags( stripslashes($v['term'])),
    			'operator' => 'NOT IN'
    			);
    
    		  }
    		  elseif(is_array($v['term'])){
    			 $taxo[] = array(
    			'taxonomy' =>  strip_tags( stripslashes($v['name'])),
    			'field' => 'slug',
    			'terms' =>$v['term'],
    			'operator' => 'AND'
    			);
    			}
    			else{
    			$taxo[] = array(
    			'taxonomy' => strip_tags( stripslashes($v['name'])),
    			'field' => 'slug',
    			'terms' => strip_tags( stripslashes($v['term']))
    			);
    			}
    		    }
    		} //end foreach
    
    		unset($output[0]);
    		return $output;				
    
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Boolean Relationship Problem’ is closed to new replies.