title: Output posts relating to the tags
body: <p>I am using <em>WordPress 3.9</em> and <em>WooCommerce 2.1.8</em>, and wanting to know how I can show a single row of four related posts that the user is currently viewing, which is relative to the <strong>tag</strong> or <strong>tags</strong> of the post, rather than the <strong>category</strong> it is in.</p>
  
  <p>Ideally, I'd like to display four products relating to the <strong>tags</strong> of the item which is currently being viewed at the bottom of my single product pages, specifically, each one of the relating post's featured images or thumbnails, and the prices.  If possible, a solution also scripted from the <em>functions.php</em> file.  </p>
  
  <p>The code below is what I have so far, which is displaying the related <strong>categories</strong> of the post, instead of the <strong>tags</strong> it is based on:</p>
  
  <pre><code>    add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
  
      function woocommerce_output_related_products() {
          $output = null;
  
          ob_start();
  
          woocommerce_related_products(array(
              'columns' =&gt; 4, 
              'posts_per_page' =&gt; 4,
              'post_type' =&gt; 'product',
              'fields' =&gt; 'ids',
              'meta_query' =&gt; $meta_query,
              'tax_query' =&gt; array(
                 'relation' =&gt;  'AND',
                   array(
                      'taxonomy' =&gt; 'product_cat',
                      'field' =&gt; 'id',
                      'terms' =&gt; $cats_array
                  ), 
                  array(
                      'taxonomy' =&gt; 'product_tag',
                      'field' =&gt; 'id',
                      'terms' =&gt; $tags_array
                  )
              )
          )); 
  
          $content = ob_get_clean();
          if($content) { $output .= $content; }
  
          echo '&lt;div class="clear"&gt;&lt;/div&gt;' . $output;
  
      } 
  </code></pre>
  
  <p>Any help would be greatly appreciated, <br/>
  Thanks.</p>