- 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
- Add custom taxonomy fields when creating a new taxonomy
- Get a list of all available fields in the User Profile
- Woocommerce add to simple product attribute programmatically [closed]
- clients list using wordpress
- Custom Taxonomy Template Post List with Sort Order
- Enabling shortcodes for custom fields
- Add options to featured image
- Using get_terms for custom taxonomy in functions.php
- How to Acheive the custom woocommerce category template
- How do I display a tag cloud with both post tags AND a custom taxonomy?
- Remove product description from product archive page
- Hide some items from Screen options in dashboard for products
- Assign category using custom field?
- Function to Download External Images to My Site
- Can you use admin pages functionality on the frontend of your site
- Creating loop within functions.php
- Adding a class to tag list in a function
- Display link to taxonomy archive only if it has posts with certain custom field values
- Display WooCommerce subscriptions for user [closed]
- How to use max and min values of custom fields
- Increment price for Woocommerce Minicart [closed]
- Change woocommerce products weight varation based its product category or tags? [closed]
- How to preserve edits to Name or Slug of term when using wp_update_term on save?
- Woocommerce checkout field maxlength, make input number field only (postcode)
- Hide custom field if empty
- change in form-checkout.php by using code in functions.php
- Set quantity of woocommerce product on page visit [closed]
- 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]
- Remove the product category module block from the Woocommerce product page
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- WordPress function saves a post twice and updates all posts
- Different Category system needed for the Custom Post Type
- Functions when woocommerce isn’t installed
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- How to get correct value from checked()?
- replace text in Sort Box
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- add referrer to woo
- Way to redirect all Product Sub Category to its Main category Page?
- Insert Address fields into function
- Get Attachment Category Name
- Adding product to WooCommerce cart [closed]
- 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
- Display ACF category image on archive and single template files
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- Customise Grouped Product display in Woocommerce with custom column
- How to Display WooCommerce Product Price in WooCommerce Archive
- 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
- wp_set_object_term via js btn frontend
- Using get_terms for custom taxonomy in functions.php
- Populate Product Regular Price with a calculated ACF Field Value
- Hide ‘add to cart’ when certain value in dropdown is selected
- Fill New Taxonomies
- Remove text after a dot and a colon in Woocommerce product title
- Woocommerce product price change
- Help with with my function for wordpress
- Get WooCommerce product category list in functions.php
- Remove clickable Link of WordPress Site Logo from Woocommerce Single Product page
- Problems adding a new field to product in cart
- I am trying to set post terms to a custom taxonomy
- How Can I Concatenate A String With One Of My Custom Field Value Before Saving The Post?
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- Variable function names
- Create New User Custom Field not Saving
- Woocommerce – Switching Price for Category
- Hide empty custom field
- add product thumbnail to checkout page only and include variation name
- Move product attributes after summary on single product page
- Which method is more correct for removing WooCommerce Extensions menu item?
- I’m getting invalid taxonomy in init action
- How to echo the translated custom field?
- How to add function to custom fields when page/post has a password?
- How to exclude posts with empty and non-existent relational custom field with meta_query?
- Insert menu into theme location depending on user logged in/out status
- How to add meta fields to custom taxonomy add/edit page?
- Define an extra field for all pages (with no plugin?)
- Custom Taxonomy as Link
- Syling Custom Fields echo’s from from functions.php
- Register custom taxonomy from a Advenced custom field option page
- Any way to make custom taxonomy field searchable?
- Issue On Listing Woocommerce Parent Tag List
- reusing code in function and running it with loop
- woocommerce_sort_product_tabs() expects an array
- How do I check if a post has a term with a particular ancestor/parent?
- sort by date in users
- Copy and Modified WooCommerce function is_coupon_valid [closed]