I would use get_queried_object()
(see this post) rather than $wp_query->query_vars
Also you should use $term->slug
(and $category->slug
) instead of $term->name
.
Apart from that, your method is as good as any.
I would use get_queried_object()
(see this post) rather than $wp_query->query_vars
Also you should use $term->slug
(and $category->slug
) instead of $term->name
.
Apart from that, your method is as good as any.