I have a view where I control the output by custom taxonomy based on query filter
Select posts with taxonomy:
TV channels slug in one of those set by the View shortcode attribute wpvtvchannels
eg. [wpv-view name="view-name" wpvtvchannels="xxxx"]
But I want the user to be able to do a front end search like this too:
Select posts with taxonomy:
TV channels slug in one of those set by the URL parameter wpvtvchannels
eg. hidden link
So I thought about making a function in my Theme functions file to prefilter the view with the channels I want included in the view.
Could you provide a sample of how this could be done?
From searching the forum here I found this:
add_filter('wpv_filter_query', 'wpv_show_prefilter_data', 99, 3);
function wpv_show_prefilter_data ( $query_args, $view_settings, $view_id ) {
if( $view_id == 273888) {
$query_args['tax_query'][] = array(
array(
'taxonomy' => 'tvchannels',
'field' => 'slug',
'terms' => 'channel4'
)
);
}
return $query_args;
}
But how do I add more than one term in the code?
If I just do the set by the URL parameter I get channels included that I do not want for this particular view.
My issue is resolved now. Thank you!
add_filter('wpv_filter_query', 'wpv_show_prefilter_data', 99, 3);
function wpv_show_prefilter_data ( $query_args, $view_settings, $view_id ) {
if( $view_id == 273888) {
$query_args['tax_query'][] = array(
array(
'taxonomy' => 'tvchannels',
'field' => 'slug',
'terms' => array( 'channel4', 'channel5', 'channel6' )
)
);
}
return $query_args;
}