F
F
foxayb2017-08-31 05:21:11
css
foxayb, 2017-08-31 05:21:11

How to make the filter conditions work?

1. There is a regular drop-down menu that, if selected, makes a post filter (according to the Ultimate WP Query Search Filter plugin)

function output_formcmf_fields($type,$metakey,$compare,$metaval,$label,$all,$i,$defaultclass,$id,$divclass ){
     $opts = explode("|", $metaval);
    
     if($type == 'dropdown'){
        $html = '<div class="'.$defaultclass.' '.$divclass.'" id="cmf-select'.$i.'"><span class="cmflabel-'.$i.'">'.$label.'</span>';
        $html .= '<input type="hidden" name="cmf['.$i.'][metakey]" value="'.$metakey.'">';
        $html .= '<input type="hidden" name="cmf['.$i.'][compare]" value="'.$compare.'">';
        $html .=  '<select id="cmfdp-'.$i.'" class="cmfdp-class-'.$i.'" name="cmf['.$i.'][value]">'; 
        if(!empty($all)){
        $html .= '<option value="uwpqsfcmfall">'.$all.'</option>';
        }
        
          foreach ( $opts as $opt ) {
            $val = explode('::',$opt);
            $selected = (isset($_GET['cmf'][$i]['value']) && $_GET['cmf'][$i]['value'] == $val[0]) ? 'selected="selected"' : '';	
            $html .= '<option value="'.$val[0].'" '.$selected.'>'.$val[1].'</option>';
          }
        $html .= '</select>';
        $html .= '</div>';
        
        return  apply_filters( 'uwpqsf_cmf_field_dropdown', $html,$type,$metakey,$compare,$metaval,$label,$all,$i,$defaultclass,$id,$divclass);
      
      }

2. There is a wrapper in which I want to wrap this filter: https://codepen.io/clintabrown/pen/KDycH?depth=eve...
Using my low-skill, I wrapped the whole thing in the following code :
function output_formcmf_fields($type,$metakey,$compare,$metaval,$label,$all,$i,$defaultclass,$id,$divclass ){
     $opts = explode("|", $metaval);
    
     if($type == 'dropdown'){
        $html = '<div class="'.$defaultclass.' '.$divclass.'" id="cmf-select'.$i.'"><span class="cmflabel-'.$i.'">'.$label.'</span>';
        $html .= '<input type="hidden" name="cmf['.$i.'][metakey]" value="'.$metakey.'">';
        $html .= '<input type="hidden" name="cmf['.$i.'][compare]" value="'.$compare.'">';
        $html .= '<input type="search-for-ddwn" id="brand-filter"  name="cmf['.$i.'][value]"  data-list="cmfdp-'.$i.'" autocomplete="off" required />';
        $html .= '<label for="brand-filter" data-icon="&#128269;"></label>';
        $html .= '<datalist id="cmfdp-'.$i.'">';
        $html .= '<select id="cmfdp-'.$i.'" class="cmfdp-class-'.$i.'" name="cmf['.$i.'][value]">'; 
        if(!empty($all)){
        $html .= '<option value="uwpqsfcmfall">'.$all.'</option>';
        }
        
          foreach ( $opts as $opt ) {
            $val = explode('::',$opt);
            $selected = (isset($_GET['cmf'][$i]['value']) && $_GET['cmf'][$i]['value'] == $val[0]) ? 'selected="selected"' : '';	
            $html .= '<option value="'.$val[0].'" '.$selected.'>'.$val[1].'</option>';
          }
        $html .= '</select>';
        $html .= '</datalist>';				
        $html .= '</div>';

But in the end it doesn't work. The whole thing looks like this: 81256b959dcb4f978ae58ef166ca93b3.PNG
Of course, if you apply the code from point 1 (native), then everything is filtered, everything is OK, but my heap does not want to work. Forgive help from hard-skill

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RAX7, 2019-05-10
@ruslan111192

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question