We have a view that has two filters on it. We would like the results from this view to show no results until a filter is chosen. It currently shows ALL results and the filters only limit the results.
I found this previous ticket:
https://toolset.com/forums/topic/how-to-require-user-to-select-at-least-one-parameter-in-custom-search/
I wanted to try to emulate that code using our filter fields, but ran into a problem. First issue is that our filters are not done on taxonomies, so I'm not sure if this code will even work for us. One of our filters is done using a custom field. The other is a dropdown list of post titles pulled through post IDs that you helped us set up previously. See code here for our two filters in the view.
-----------------------------------------------------
<div class="form-group">
<label for="wpv-wpcf-ride-start-county" style="font-weight: bold;">[wpml-string context="wpv-views"]Filter Rides by County[/wpml-string]</label>
[wpv-control-postmeta type="checkboxes" field="wpcf-ride-start-county" url_param="wpv-wpcf-ride-start-county"]
</div>
<div class="form-group">
<label for="ride-post-id" style="font-weight: bold;">[wpml-string context="wpv-views"]Select Ride by Name[/wpml-string]</label>
[wpv-view name="ride-post-titles-dropdown"]
</div>
-----------------------------------------------------
So for the purposes of using your code provided in that other support ticket, I'm thinking that I'd need to define the county field as follows:
( isset($_GET['wpv-wpcf-ride-start-county']) && $_GET['wpv-wpcf-ride-start-county'] != '0' )
But then I'm not clear on how I'd define the second filter. That is not a field. Would I just use
( isset($_GET['ride-post-id']) && $_GET['ride-post-id'] != '0' )
In the query filter section of the view, this filter is defined as:
Post ID filter
Include only posts with IDs determined by the URL parameter "wpv-ride-post-id" eg. yoursite/page-with-this-view/?wpv-ride-post-id=1
So I'm not sure if I should use
( isset($_GET['wpv-ride-post-id']) && $_GET['wpv-ride-post-id'] != '0' )
Or do I need to do something else with this? Any help you can provide will be appreciated.