- First check it is product category archive page using
is_tax
- Then use
get queried object_id
to get the currentterm ID
- Then after you can use
get_term_meta
to get class name.
Example:
add_filter( 'body_class', 'lalka_custom_taxonomy_in_body_class' );
function lalka_custom_taxonomy_in_body_class( $classes ){
if (is_tax('product_cat')) {
$custom_class = !empty( get_queried_object_id() ) ? get_term_meta(get_queried_object_id(), 'custom-class', true) : FALSE;
if ( !empty($custom_class) ) {
$classes[] = 'custom-tax-' . $custom_class;
}
}
return $classes;
}
Related Posts:
- How to display custom field in woocommerce orders in admin panel?
- Identical custom taxonomy slugs for same hierarchical children
- How to display custom option field in woocommerce orders in admin panel?
- How to add a slide toggle to the Woocommerce-Layout__Activity-Panel area in the orders admin page
- Redirect to another page using contact form 7? [closed]
- Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma
- Taxonomy On Index Page
- Only seems to be displaying one child when there are supposed to be multiple
- How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]
- Load Woocommerce and WordPress Functions Outside
- How to add textarea field to taxonomy (tag)?
- Add to cart php not working [closed]
- Hide product categories and taxonomy terms in menu if empty
- Move ‘current-menu-item’ class on #adminmenu li from Posts to Pages for Taxonomy Edit Screen
- How to auto refresh when user change postcode
- What WordPress function to use to get meta value by using meta keys?
- When sale price is 0.00 show only regular price
- Remove the product category module block from the Woocommerce product page
- Removing custom meta data
- how can I edit flexslider in woocommerce. [Urgent]
- Change label for registration Fields
- Custom Attachment Caption Fields
- woocommerce custom product category template
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- woocommerce change currency per category [closed]
- Default Custom Field Value Automatically Update
- Is there a WP function to get taxonomy name from taxonomy_term_id?
- Get list of all custom tanonomy id
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Multi-select field for Taxonomy can’t save the value
- WordPress function saves a post twice and updates all posts
- Different Category system needed for the Custom Post Type
- ACF not showing
- help I changed one currency in woocommerce and everything is ruined [closed]
- WordPress implode & wp_insert_post question
- Functions when woocommerce isn’t installed
- How to override woocommerce.css?
- How can I use Woocommerce $product->get_attribute in functions.php? (if at all)
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- How to get correct value from checked()?
- Prevent custom field from being updated after first publish
- (Woocommerce) Order by price when entering specific category
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Targeting categories in custom fields
- Output a specific link in WordPress post if the single post’s category’s name contain certain word
- Create custom function for hero image
- Hierarchical taxonomy list with modificated term links
- replace text in Sort Box
- add_filter to specific WooCommerce Category
- Programmatically add Yoast meta description after post save
- Woocommerce checkout field
- Possible to merge these two functions?
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- add referrer to woo
- Exclude product attributes from taxonomy terms loop
- WP All Import / Update stock quantity from multiple XML files
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- Way to redirect all Product Sub Category to its Main category Page?
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- Insert Address fields into function
- Create a Woocommerce product widget with category filter
- Filter through custom taxonomy with an array of taxonomy IDs
- Delay a function, any function!
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- Loop through custom taxanomy in post and display custom fields from posts
- How to make custom comment fields required
- Get Attachment Category Name
- Suggest Users basing on User taxonomy
- Adding product to WooCommerce cart [closed]
- Change WooCommerce add_to_cart Button Text?
- WooCommerce -> wc_enqueue_js not working [closed]
- Use existing image sizes for WooCommerce
- How do I display a date correctly that is stored in the database as a backwards 8 digit number from Advanced Custom Fields? [closed]
- Sort and display pages with specific custom field (not tag)
- shorthand syntax for custom fields
- Fill empty custom field with other custom field
- Perform function on publish AND save (not just save)
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- Display ACF category image on archive and single template files
- Get URLs for AJAX Filter Checkboxes WordPress
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- Customise Grouped Product display in Woocommerce with custom column
- How to change the author box selection on a post to a custom taxonomy
- How to Display WooCommerce Product Price in WooCommerce Archive
- How to change text color depending on the number value (Using javascript)
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Add custom taxonomy using JS in post editor
- How to hide content on mobile in the functions.php file – woocommerce
- Woocommerce Default sorting product by product type
- How to hide WooCommerce product title and short description to non logged in users?
- How to hide a child category and show his parent category
- Display a list of random terms from custom taxonomy with shortcode
- How to add custom metakey to shop_order page’s searching function?
- wp_set_object_term via js btn frontend
- localize_script but data changes dependent on product ID
- Using get_terms for custom taxonomy in functions.php
- Changing the HTML of notices in WooCommerce [closed]
- Change class woocommerce on function.php
- Show ‘Add to Cart’ on Out of Stock products