How to get color code in woocommerce color attribute by slug in wordpress
You can get color code in wordpress woocommerce color attribute by slug in wordpress.
You can use this code wordpress plugin woocommerce-products-filter also
By using just simple code.
First you need to get the $term['term_id']. This can be array
Or object $term->term_id according to your page
Use this code then for array:
$color_code_array = get_term_meta($term['term_id']);
$colorp = $color_code_array['color_value'][0]; // #000111
Use this code then for Object:
$color_code_array = get_term_meta($term->term_id);
$colorp = $color_code_array['color_value'][0]; // #000111
Now you print echo $colorp; // #000111
Comments
Post a Comment