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

The subcategory listing page has route as'


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?

1 Answer 1


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.