I've created a category archive for my custom post type. I've created a view to show the subcategories of the current parent category. I've used the Taxonomy parent filter "Select taxonomy terms whose parent is the current taxonomy archive" to achieve that, which works fine.
However, we want those subcategories also on a subcategorie page. Now, if I select a subcategory, the subcategory menu disappears. We want to keep it, and style the current subcategory like I can with a normal nav menu. Is that possible?
When on a child term archive the taxonomy filter that sets the parent according to the current taxonomy archive uses the child term, but you need it to be its parent.
The only solution that comes to mind is to modify the query arguments for your View that outputs the terms which you insert into the archive.
If the current archive term has no parent then we don't need to change anything, but if it does have a parent, that's what we need to use.
The following code should achieve that, if you want to test it and confirm that it works. You'll need to edit the ID of the View.
function ts_mod_tax_archive( $query_settings, $view_settings, $view_id ){
if ( $view_id == '202' ){
global $wp_query;
$obj = $wp_query->get_queried_object();
if ( $obj->parent != 0 ){
$query_settings['child_of'] = $obj->parent;
}
}
return $query_settings;
}
add_filter( 'wpv_filter_taxonomy_query', 'ts_mod_tax_archive', 101, 3 );
This was quite advanced for me, I expected this to be easier with Toolset to be honest since it's a pretty common thing. But I was able to get it to work with your help, thanks for that!