php - 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 pag

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

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
    }
    

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744593657a4582760.html

相关推荐

  • php - 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 pag

    2天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信