title: Order by custom Woocommerce product sorting in a WP_Query
body: <p>I have created a shortcode to display products by category with the query below:</p>
  
  <pre><code>$atts = shortcode_atts( array (
          'type' =&gt; 'product',
          'posts' =&gt; -1,
          'category' =&gt; '',
      ), $atts, 'list_products' );
  
      $query = new WP_Query( array(
          'post_type' =&gt; $atts['type'],
          'posts_per_page' =&gt; $atts['posts'],
          'tax_query' =&gt; array( array(
               'taxonomy' =&gt; 'product_cat',
               'field' =&gt; 'slug',
               'terms' =&gt; $atts['category'],
          ) ),
      ) );
  </code></pre>
  
  <p>This is all fine, however I am trying to use the order by attribute when I sort the products using the custom sort <a href="https://docs.woocommerce.com/document/managing-products/#section-23" rel="nofollow noreferrer">shown here</a></p>
  
  <p>I have added: <code>'orderby' =&gt; 'modified',</code> and <strong>tried</strong> some others from <a href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Two questions:</p>
  
  <p>Which attribute do I need to use to sort when using custom sorting</p>
  
  <p>And</p>
  
  <p>What do I need to do to make my <code>orderby</code> attribute work when added to the above query? Because it which ever attribute value I use it always sorts by published descending.</p>