I will explain it to you without code at the moment, but in things need to be done:
- Before you render your category html, check its position (depth) from its current category upwards to the parent category.
- If the level is 2, then add the style you want to post_class (post_class($array)), otherwise do not add.
Check this answer for getting the ancestors of a category:
Get the the top-level parent of a custom taxonomy term
Check this to see more about post_class():
Related Posts:
- retrieve thumbnail from post ID of best selling product in category
- Woocommerce – remove product from category
- combine Code 1 with Code 2
- get current product name in functions.php
- Issue adding sub category programmatically
- Pass Category Name, Description and Photo into variables to pass to jQuery
- get taxonomy thumbnail and use it as a variable in code
- Only show size attributes in product box woocommerce when available
- WooCommerce: Display product categories to make IF statement
- Display Sibling WooCommerce Product Categories on Archive Page
- Woocommerce. Get a list of products in the current category on the archive page and product page
- Add Custom Category Description When Empty
- Add a product category to a specific product via a button
- random woocommerce categories are not showing when count enabled?
- Need Quick Help With Product Category Page
- WordPress using get_term to retreive slug not working as expected
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- Woocommerce get selected shipping zone id for the current user
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- How to show order data by multiple ID?
- Problem with Woocommerce REST API Authentication
- Categories Template Assistance
- Remove General Tab and Plugin Tab in Settings in Woocommerce
- WooCommerce – Display variation custom field value [closed]
- Problems with function on function.php
- Woocommerce HTML email option unavailable
- Use template for posts with a particular category grandparent
- How to add SVG icon above product tab title
- How to change / delete product short description in Woocommerce
- How to trash multiple post/product programmatically
- OrderItem get_total() returns lower value than $order_item->get_product()->get_price() * quantity
- Custom category code not showing all posts
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- WooCommerce – Reset quantity input field when variation changes
- Custom Text in WooCommerce Order Processing Email Based on Products
- How can I apply_filters from inside a function?
- Different Minimum Order Amounts based on Shipping Zone [closed]
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Displaying Woocommerce Product Category in WordPress
- Displaying custom taxonomy on WooCommerce product page
- Change “add to cart” button color based on Woocommerce product category [closed]
- Add to cart function not working for first product when cart is empty [closed]
- Woocommerce : Can’t get product info in loop
- Let Users Choose Post Categories
- Display most popular posts of category
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- Single Quotes in .php file doesn’t load website
- How to upload WP user avatar on woocommerce account page [closed]
- How to relocate paypal button gateway on checkout page in woocommerce
- Argument for if term-> have child?
- How do I run code every 24 hours?
- Woocommerce Product_cat for current category page
- Echoing a CSS class based on category of post in a list
- How do i wrap woocomerce attribute in list?
- Removing files programmatically
- WooCommerce “Checkout Now” button [closed]
- Showing Subcategory Name/Link Instead of Parent Category
- WordPress custom taxonomy
- Finding and removing duplicates within WP Arrays
- Compare current post Category in select menu
- Get the list of post categories
- How can I enter on the Thank you page in woocommerce the discount code I assigned to the product category?
- How to show categories and date on posts
- Woocommerce append shipping method form
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- Allow two posts (from different categories) to have the same slug
- How do I check if a product is in two categories?
- php code for outputting a custom page in my account
- Hide specific shipping methode depending on day and time of day
- Adding custom field to product category and show it to shop/category shop page
- How to hide a div section when user is logged in, in single product woocommerce
- Remove span tags from WooCommerce Downloads page
- How to enable HTML tags in category description without breaking the category page
- Global variable doesnt’t pass to another function
- Exclude category from woocommerce product category list
- Trying to show the category of a post in the post display
- Edit woocommerce_product_archive_description using hook
- How to empty price of simple and variable product when product changed into out off stock
- How to create loop inside wordpress function?
- How to auto-generate random numbers in username?
- Remove generated category and tag class names from woocommerce product & blog listings markup
- How to echo a PHP code into WooCommerce variation product?
- Get Billing Email from WooCommece Checkout and Pass to Fullstory JS
- Woocommerce custom attributes list help
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- Global filter not working
- Code works on page-example.php by not category-example.php
- WooCommerce remove_action and add_action [closed]
- get_category display only 1
- Make an array listing custom taxonomy
- Get category id for a custom category and display it in a class
- wp_get_archive for category returning different URLs on different but similar sites
- How to add margin underneath woocommerce total price amount -> productpages
- How to find the value of the user password in wordpress and send it to another server via rest api
- Change Checkout “Place Order” text if cart has a specific product
- Grabbing value of input field inside of array
- How to set variable to specific field when querying
- WooCommerce Checkout Cart [closed]
- Woocommerce – add tracking code to another email template