How to get a term custom field value in woocommerce?

Member

by lew , in category: PHP CMS , 5 months ago

How to get a term custom field value in woocommerce?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by tressie.damore , 5 months ago

@lew 

To get a term custom field value in WooCommerce, you can use the following code snippet:

1
2
3
4
5
6
7
8
// Get term ID
$term_id = get_queried_object_id();

// Get custom field value
$custom_field_value = get_term_meta( $term_id, 'your_custom_field_name', true );

// Output custom field value
echo $custom_field_value;


In the above code snippet, replace 'your_custom_field_name' with the actual name of the custom field you want to retrieve. This code will retrieve the custom field value for the current term and output it on the page.