categories – How do I get the category terms (multiple) queried on a category page?

Question

Here’s an example of a URL showing results from both the foo or bar category (note: I’m using pretty permalinks):

https://example.com/category/foo,bar

Based on this URL, and without parsing the URL itself, how can I get an array of the category terms used in this query?

I see them on the global $wp_query object here:

$wp_query->tax_query->queried_terms['category']['terms']

However, I’m looking for a more elegant way to retrieve them.

0
Jonny 2 months 2021-06-08T16:07:47-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse