Title: Function code wpml compatible
Last modified: December 21, 2018

---

# Function code wpml compatible

 *  [nvr21](https://wordpress.org/support/users/nvr21/)
 * (@nvr21)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/function-code-wpml-compatible/)
 * Hey there,
    I really love your code to display custom attribute but i have some
   issue with wpml it doesn’t translate the attributes only variations. Can you 
   help made this functions wpml compatible? Thanks in advance. PS: function is 
   enough no need to install your full plugin. 😀
 *     ```
       function isa_woocommerce_all_pa(){
   
           global $product;
           $attributes = $product->get_attributes();
           if ( ! $attributes ) {
               return;
           }
   
           $out = '<ul class="custom-attributes">';
   
           foreach ( $attributes as $attribute ) {
   
   
               // skip variations
               if ( $attribute->get_variation() ) {
               continue;
               }
               $name = $attribute->get_name();
               if ( $attribute->is_taxonomy() ) {
   
                   $terms = wp_get_post_terms( $product->get_id(), $name, 'all' );
                   // get the taxonomy
                   $tax = $terms[0]->taxonomy;
                   // get the tax object
                   $tax_object = get_taxonomy($tax);
                   // get tax label
                   if ( isset ( $tax_object->labels->singular_name ) ) {
                       $tax_label = $tax_object->labels->singular_name;
                   } elseif ( isset( $tax_object->label ) ) {
                       $tax_label = $tax_object->label;
                       // Trim label prefix since WC 3.0
                       if ( 0 === strpos( $tax_label, 'Product ' ) ) {
                          $tax_label = substr( $tax_label, 8 );
                       }                
                   }
   
   
                   $out .= '<li class="' . esc_attr( $name ) . '">';
                   $out .= '<span class="attribute-label">' . esc_html( $tax_label ) . ': </span> ';
                   $out .= '<span class="attribute-value">';
                   $tax_terms = array();
                   foreach ( $terms as $term ) {
                       $single_term = esc_html( $term->name );
                       if ( $single_product ) {
                       $term_link = get_term_link( $term );
                       if ( ! is_wp_error( $term_link ) ) {
               $single_term = '<a href="' . esc_url( $term_link ) . '">' . esc_html( $term->name ) . '</a>';
           }
       }
                       array_push( $tax_terms, $single_term );
                   }
                   $out .= implode(', ', $tax_terms);
                   $out .= '</span></li>';
   
               } else {
                   $value_string = implode( ', ', $attribute->get_options() );
                   $out .= '<li class="' . sanitize_title($name) . ' ' . sanitize_title( $value_string ) . '">';
                   $out .= '<span class="attribute-label">' . $name . ': </span> ';
                   $out .= '<span class="attribute-value">' . esc_html( $value_string ) . '</span></li>';
               }
           }
   
           $out .= '</ul>';
   
           echo $out;
       }
       add_action('woocommerce_single_product_summary', 'isa_woocommerce_all_pa', 25);
       ```
   

The topic ‘Function code wpml compatible’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/woocommerce-show-attributes_d1b9b7.
   svg)
 * [WooCommerce Show Attributes](https://wordpress.org/plugins/woocommerce-show-attributes/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-show-attributes/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-show-attributes/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-show-attributes/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-show-attributes/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-show-attributes/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [nvr21](https://wordpress.org/support/users/nvr21/)
 * Last activity: [7 years, 5 months ago](https://wordpress.org/support/topic/function-code-wpml-compatible/)
 * Status: not resolved