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


Here’s an example of a URL showing results from both the foo or bar category (note: I’m using pretty permalinks):,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:


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

in progress 0
Jonny 6 months 2021-06-08T16:07:47-05:00 0 Answer 0 views 0

Answer ( 1 )


    How about explode( ',', $wp_query->get( 'category_name' ) )

Leave an answer