title: Listing Product Attributes in Alphabetical Order (Woocommerce)
body: <p>For starters thank you for taking a look / any assistance you may offer. </p>
  
  <p>I am trying to create a custom page template that creates a list in alphabetical order displaying all the results for a specific (Woocommerce) product attribute across my site. </p>
  
  <p>So in my case the product attribute is "Artist" </p>
  
  <p>I found some code that does a similar thing for posts, which altered gives this: </p>
  
  <pre><code>&lt;?php 
  /*
  Template Name: Artists
  
  */
  $posts_per_row = 4;
  $posts_per_page = 400;
  ?&gt;
  
  &lt;?php get_header(); ?&gt;
  &lt;?php get_template_part( 'headers/page', 'header' ); ?&gt; 
  
  &lt;style type="text/css"&gt;
  .letter-group { width: 100%; }
  .letter-cell { width: 5%; height: 2em; text-align: center; padding-top: 8px; margin-bottom: 8px; float: left; }
  .row-cells { width: 75%; float: right; margin-right: 180px; }
  .title-cell { width: 25%;  float: left; overflow: hidden; margin-bottom: 8px; }
  .clear { clear: both; }
  &lt;/style&gt;
  
   &lt;div class="ps-container"&gt;
          &lt;div class="container clearfix"&gt;
  &lt;div id="main-background"&gt;
  
     &lt;div id="main-column"&gt;
        &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
  
        &lt;div class="margin-top"&gt;&lt;/div&gt;  
  
        &lt;div id="a-z"&gt;
  
           &lt;?php
           $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
           $args = array (
              'posts_per_page' =&gt; $posts_per_page,
              'post_type' =&gt; 'product',
              'orderby' =&gt; 'title',
              'order' =&gt; 'ASC',
              'paged' =&gt; $paged
           );
           query_posts($args);
           if ( have_posts() ) {
              $in_this_row = 0;
              while ( have_posts() ) {
                 the_post();
                 $first_letter = strtoupper(substr(apply_filters('the_title',$post-&gt;post_title),0,1));
                 if ($first_letter != $curr_letter) {
                    if (++$post_count &gt; 1) {
                       end_prev_letter();
                    }
                    start_new_letter($first_letter);
                    $curr_letter = $first_letter;
                 }
                 if (++$in_this_row &gt; $posts_per_row) {
                    end_prev_row();
                    start_new_row();
                    ++$in_this_row;  // Account for this first post
                 } ?&gt;
                 &lt;div class="title-cell"&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link to &lt;?php the_title_attribute(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/div&gt;
              &lt;?php }
              end_prev_letter();
              ?&gt;
              &lt;div class="navigation"&gt;
                 &lt;div class="alignright"&gt;&lt;?php next_posts_link('Next Page &amp;raquo;') ?&gt;&lt;/div&gt;
                 &lt;div class="alignleft"&gt;&lt;?php previous_posts_link('&amp;laquo; Previous Page') ?&gt;&lt;/div&gt;
              &lt;/div&gt;
           &lt;?php } else {
              echo "&lt;h2&gt;Sorry, no artists were found!&lt;/h2&gt;";
           }
           ?&gt;
  
        &lt;/div&gt;&lt;!-- End id='a-z' --&gt;
  
     &lt;/div&gt;&lt;!-- End class='margin-top --&gt;
  
  &lt;/div&gt;&lt;!-- End id='rightcolumn' --&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;?php get_footer(); ?&gt;
  
  &lt;?php
  function end_prev_letter() {
     end_prev_row();
     echo "&lt;/div&gt;&lt;!-- End of letter-group --&gt;\n";
     echo "&lt;div class='clear'&gt;&lt;/div&gt;\n";
  }
  function start_new_letter($letter) {
     echo "&lt;div class='letter-group'&gt;\n";
     echo "\t&lt;div class='letter-cell'&gt;$letter&lt;/div&gt;\n";
     start_new_row($letter);
  }
  function end_prev_row() {
     echo "\t&lt;/div&gt;&lt;!-- End row-cells --&gt;\n";
  }
  function start_new_row() {
     global $in_this_row;
     $in_this_row = 0;
     echo "\t&lt;div class='row-cells'&gt;\n";
  }
  
  ?&gt;
  </code></pre>
  
  <p>Now to alter this, I tried using get attribute in place of the array retrieving my posts, as I normally do in other spots of my site using:</p>
  
  <pre><code>global $product;    
  $product-&gt;get_attribute( ‘pa_attribute’ )
  </code></pre>
  
  <p>But nothing is working.</p>
  
  <p>Can anyone shed some light on my issue? I get it showing posts just fine, but I can't transition this to properly list the Artists names instead of product (post) names.</p>
  
  <p>Thank you.</p>