wc_attribute_taxonomy_name_by_id

Get a product attribute name by ID.

Description

(string) wc_attribute_taxonomy_name_by_id( (int) $attribute_id ); 

Returns (string)

Return an empty string if attribute doesn't exist.

Parameters (1)

0. $attribute_id (int)
The attribute id.

Usage

  1. if ( !function_exists( 'wc_attribute_taxonomy_name_by_id' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-attribute-functions.php'; 
  3.  
  4. // The attribute id. 
  5. $attribute_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_attribute_taxonomy_name_by_id($attribute_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-attribute-functions.php  
  1. function wc_attribute_taxonomy_name_by_id( $attribute_id ) { 
  2. global $wpdb; 
  3.  
  4. $attribute_name = $wpdb->get_var( $wpdb->prepare( " 
  5. SELECT attribute_name 
  6. FROM {$wpdb->prefix}woocommerce_attribute_taxonomies 
  7. WHERE attribute_id = %d 
  8. ", $attribute_id ) ); 
  9.  
  10. if ( $attribute_name && ! is_wp_error( $attribute_name ) ) { 
  11. return wc_attribute_taxonomy_name( $attribute_name ); 
  12.  
  13. return '';