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?
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?
Share Improve this question asked Apr 6, 2020 at 8:05 Saeesh TendulkarSaeesh Tendulkar 1531 silver badge7 bronze badges1 Answer
Reset to default 0Do this code on category-archive
template.
- Fetch queried object using
get_queried_object()
. - Check if the parent value in returned object is 0 or not.
If it is not 0 then run your code.
$category = get_queried_object(); if($category->parent != 0){ //write your code here }