Tell us what you are trying to do?
I would like to create a view that only displays posts (custom post) of a parent taxonomy but then includes on page filters to filter by sub categories.
I'm going to use Genres for an example as I think its an easier way to explain than the working version.
Parent Taxonomy = Action
Child Taxonomy = Martial Arts, War & Military, Shoot 'Em Up
Parent Taxonomy = Drama
Child Taxonomy = Caper, Slapstick, Stand-up
In my example I want the two parent taxonomies to be completely separate and the results for each will be displayed on different pages.
I have it working to an extent by adding the following to pre_get_posts, the problem with this is. Should the user have made a mistake and added the post to categories in both parent taxonomies, the on page filter will display them.
function define_parent_query( $query ) {
global $WP_Views;
if ( $WP_Views->current_view == 21657 ) {
$taxquery = array(
array(
'taxonomy' => 'video-category',
'field' => 'slug',
'terms' => 'action',
'operator'=> 'IN'
)
);
$query->tax_query->queries[] = $taxquery;
$query->query_vars['tax_query'] = $query->tax_query->queries;
/* $query->set( 'tax_query', $taxquery ); */
}
}
I have also looked into using wpv_filter_query to exclude / include the specific categories but it either displays every post or none.
Is there any documentation that you are following?
https://toolset.com/forums/topic/filter-categories-pre_get_posts-not-working/