Support

Account

Home Forums ACF PRO Search form with meta_field Reply To: Search form with meta_field

  • Hi @beee

    I think your approach is the best method for this situation. You can also use the $_POST variable to get the field you want to search. So, you should be able to do it like this:

    <input type="hidden" name="custom_field" value="field_name" />

    And modify the query like this:

    if( isset($_POST['custom_field']) ){
        // set the meta query for your specific field
        $query->set( 'meta_query', array(
            'key'       => $_POST['custom_field'],
            'value'     => $query->query['s']
        ) );
    }

    I hope this makes sense 🙂