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.
Here is a one liner:
$wp_query->get_queried_object()->term_id;
or
$wp_query->get_queried_object()->name;
or
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With