[ad_1]
I’ve got a function which checks if the page is a category, product, or page and displays different content.
The issue I’m having is, no matter where I reference the `global $post` variable I end up getting the context of the first product within that category. How can I ensure that on a category page, the code will have the context of that category rather than the top product?
TIA
[ad_2]
Have you taken a look at [get_queried_object()](https://developer.wordpress.org/reference/functions/get_queried_object/) ?