Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce: Get current product category

Tags:

woocommerce

How do I get the current product category that the user is browsing through?

I am trying to use get_the_terms($post->ID, 'product_cat'); but this is giving me the categories for each product listed on the page. I would like to get the current category user is browsing through, the current product listing page.

like image 657
Caio Mars Avatar asked Jun 09 '14 16:06

Caio Mars


1 Answers

Here is a one liner:

$wp_query->get_queried_object()->term_id;

or

$wp_query->get_queried_object()->name;

or

...
like image 187
Etienne Dupuis Avatar answered Nov 11 '22 22:11

Etienne Dupuis