Forums › Forums › Search & Filter Pro › input field for post meta value search?
Tagged: Range search
- This topic has 6 replies, 2 voices, and was last updated 7 years, 11 months ago by Anonymous.
-
Anonymous(Private) November 26, 2016 at 5:16 am #72415
How do I create single input field like search form for post meta value search?
For example, zip code search.
There is a custom post type that have zip_min’ & ‘zip_max’ custom field.
And I’d like to have users input their zip code and search posts that input zip code is in range of its zip_min and zip_max.I’m thinking to set meta_query in sf_edit_query_args() but I don’t know how to create input field for that.
Anonymous(Private) November 29, 2016 at 8:13 pm #72977Actually what I want is not that user select range of value and search single custom field.
I want to have user input single number and search two custom fields see if number is in range of two.I tried this in sf_edit_query_args to catch search form value and set it to custom fields.
$zip=$query_args['s']; unset($query_args['s']); $query_args['meta_query']=Array(Array('key'=>'zip_min','value'=>$zip,'compare'=>'<=','type'=>'NUMERIC,'),Array('key'=>'zip_max','value'=>$zip,'compare'=>'>=','type'=>'NUMERIC,'));
So far it seems to to working but I’m not sure this is proper way.
-
AuthorPosts