wp query – How to get value of a selected option from select tag and use it in WP_query to filter posts?

Question

This is how I’m getting the value but how to use it in WP_Query so when I click Search to display let’s say posts with Option 1 value?

I’m doing this but don’t know if meta_value is the answer

$search_query=new Wp_Query($search_args);
$something=isset($_GET['something'])&&$_GET['something']?$_GET['something']:'';

    if($something){
         $search_args['meta_value']=$something;
    }

<select name="something" id="" class="" 
style="width: 100%;">
            <option value="Something">Something</option>
            <option value="Option 1">Option 1</option>
            <option value="Option 2">Option 2</option>
        </select>

0
Jets 3 years 2018-06-13T11:51:35-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse