I have two taxonomies in wordpress under my Events custom post type.
One taxonomy is States, the other is Event Type.
I have a taxonomy-states.php and a taxonomy-event-type.php.
However sometimes I run a query between both taxonomies such as
mysite.com/events/?state=texas&event-type=football, which picks up the taxonomy-states.php template.
When I run the above I use wordpress rewrite to get mysite.com/events/texas/football
I essentially need different options in my taxonomy-states.php template if the user is viewing two taxonomies vs just the one state taxonomy.
So my question is when I query two taxonomies, how can I dynamically check for this in wordpress?
Try looking at
$wp_query->query_vars['tax_query']– this should hold the taxonomy query(which I assume will be used, since you’re making a more complicated(two or more taxonomies) taxonomy query.If you don’t find the information there though, just have a look at the
$wp_query->query_varsproperty. Do either avar_dump( $wp_query->query_vars );orprint_r( $wp_query->query_vars );and you will see what the query is. From there you should be able to figure it out what tells you when you’re querying for two taxonomies, vs just for one.