title: WP query_posts group by meta field related
body: <p>Hello Guys i am trying to customize a wordpress theme and am getting this is How it queries All Posts with episodes post_type.</p>
  <p>My Question Is.</p>
  <p>this Post type is related to another post_type which is called tvshows so each post in that is post_type epsidoes has a meta_field called series which specifies the tvshow this postis related to.</p>
  <p>for example There is <code>series one post</code> which is <code>post_type = tvshows</code> it's <code>id is 20</code></p>
  <p>and there are 2 posts in post_type = episodes, both these posts have meta_feild called series and both are related to the tvshow above so they have there meta_field series=20 which is the id of tvshow post type.</p>
  <p>The problem in my query below is it shows all post in the post type episodes and i want it to show related posts once for example if 2 posts which are epsidoes share 1 tvshow i want to show them once like on database we use group by right but then i want to show the latest by date or name</p>
  <p>so basically am saying i want to display all episode posts but latest once group by meta field series or show post which have same meta field once</p>
  <pre><code>
  // Compose Query
  $query = array(
      'post_type' =&gt; array('episodes'),
      'showposts' =&gt; 10,
      'orderby'   =&gt; 'date',
      'order'     =&gt; 'DESC'
  );
  &lt;div &lt;?php if($slid) echo 'id=&quot;dt-episodes&quot; '; ?&gt;class=&quot;animation-2 items &lt;?php echo $maxwidth; ?&gt;&quot;&gt;
      &lt;?php query_posts($query); while(have_posts()){ the_post(); get_template_part('inc/parts/item_ep'); } wp_reset_query(); ?&gt;
  &lt;/div&gt;
  </code></pre>