I have been having some problems with a complex parametric search I am setting up.
The search is of a child post type, with two different classes of parent.
I have set up the view to display a table including fields and taxonomies from both the child post type and both parents and wish to set up filters to appear above the table.
The issues I am facing with this view are:
1. I am trying get a filter to display posts between two dates. Unfortunately it is not returning any results.
I am using the auto generated code:
<div class="form-group">
<label for="wpv-wpcf-funding-event-date_min">[wpml-string context="wpv-views"]From[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-funding-event-date" url_param="wpv-wpcf-funding-event-date_min"]
</div>
<div class="form-group">
<label for="wpv-wpcf-funding-event-date_max">[wpml-string context="wpv-views"]To[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-funding-event-date" url_param="wpv-wpcf-funding-event-date_max"]
</div>
2. I am also wanting to enable filtering by taxonomies of the parents. I have tried following the guidance provided by Luo here: https://toolset.com/forums/topic/parametric-search-with-parent-field/
I have modifed the code in that example but can't get it to work.
the code for the functions file I used was:
/**
* Custom code to enable filtering of funding events by Company-profile category
*/
add_filter( 'wpv_filter_query', 'filter_application_by_category_func', 10, 3 );
function filter_application_by_category_func( $query_args, $settings, $view_id ) {
if($view_id == 207 && isset($_GET['category']) && !empty($_GET['category'])){
$args = array(
'post_type' => 'company-profile',
'fields' => 'ids',
'meta_key' => 'wpcf-category',
'meta_value' => $_GET['category'],
'meta_compare' => 'IN',
);
$parent_ids = get_posts( $args );
$parent_ids[] = 0;
if(!isset($query_args['meta_query'])){
$query_args['meta_query'] = array();
}
$query_args['meta_query'][] = array(
'key' => '_wpcf_belongs_funding-event_id',
'value' => $parent_ids,
'compare' => 'IN',
);
}
return $query_args;
}
I inserted the following in the view:
[wpml-string context="wpv-views"]Category:[/wpml-string]
[wpv-control-post-taxonomy taxonomy="category" url_param="category" type="select" auto_fill="wpcf-category" auto_fill_sort="asc" auto_fill_default="All"]
Not sure what I am doing wrong.
Could you please help?
Cheers
Peter