0

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?

user1609391
  • 445
  • 1
  • 9
  • 24

2 Answers2

0

In taxonomy-states.php, just test both $_GET['state'] and $_GET['event-type']. If both are set, execute some code. If only one, execute another block of code.

barakadam
  • 2,179
  • 1
  • 16
  • 15
0

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_vars property. Do either a var_dump( $wp_query->query_vars ); or print_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.

Nikola Ivanov Nikolov
  • 5,022
  • 1
  • 26
  • 27