Filter for product subcategory listing page load

I need to run a code when the subcategory listing page loads in a woocommerce wordpress site.

The subcategory listing page has route as'

/product-category/{catgeory}/{sub-category}.

I need a filter which I can hook upon when this page loads and run a code. I could also run the code in the template file of the route. But I can't find it. Can anyone help?

Topic woocommerce-offtopic listing php Wordpress

Category Web


Do this code on category-archive template.

  1. Fetch queried object using get_queried_object().
  2. Check if the parent value in returned object is 0 or not.
  3. If it is not 0 then run your code.

    $category = get_queried_object();
    if($category->parent != 0){
         //write your code here
    }
    

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.