title: Show WooCommerce product attributes in custom home and product category archives
body: <p>The below code that displays product attributes on product category archive pages and is based on <em>"<a href="https://stackoverflow.com/questions/53510707/display-product-attributes-on-specific-woocommerce-product-category-archives-pag/53510826#53510826">Display product attributes on specific Woocommerce product category archives page</a>"</em> answer thread. </p>
  
  <p>However, when I add that category on the homepage, It does not display the attributes.</p>
  
  <p>My code version:</p>
  
  <pre><code>// Show Attributes on Product Category Page 
  add_action('woocommerce_after_shop_loop_item','display_loop_product_attribute' );
  function display_loop_product_attribute() {
      global $product;
  
      //$product_attributes = array('pa_size', 'pa_color');
      $product_attributes = array('pa_size');
      $attr_output = array();
  
      // Loop through the array of product attributes
      foreach( $product_attributes as $taxonomy ){
          if( taxonomy_exists($taxonomy) ){
              if( $value = $product-&gt;get_attribute($taxonomy) ){
                  // The product attribute label name
                  $label_name = get_taxonomy($taxonomy)-&gt;labels-&gt;singular_name;
                  // Storing attributes for output
                  $attr_output[] = '&lt;span class="'.$taxonomy.'"&gt;'.$label_name.': '.$value.'&lt;/span&gt;';
              }
          }
      }
      // Output attribute name / value pairs separate by a "&lt;br&gt;"
      echo '&lt;div class="product-attributes-custom"&gt;'.implode('&lt;br&gt;', $attr_output).'&lt;/div&gt;';
  }
  </code></pre>
  
  <p>I can't figure out how to make it work on my custom homepage that display products and on specific product category pages. For the homepage I know that the conditional tag to be used is <strong><code>is_home()</code></strong>… But how can I make it work for product category pages too?</p>