最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Filter for product subcategory listing page load

programmeradmin4浏览0评论

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
    }
    
发布评论

评论列表(0)

  1. 暂无评论