admin管理员组文章数量:1196987
Hello Guys i am trying to customize a wordpress theme and am getting this is How it queries All Posts with episodes post_type.
My Question Is.
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.
for example There is series one post
which is post_type = tvshows
it's id is 20
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.
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
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
// Compose Query
$query = array(
'post_type' => array('episodes'),
'showposts' => 10,
'orderby' => 'date',
'order' => 'DESC'
);
<div <?php if($slid) echo 'id="dt-episodes" '; ?>class="animation-2 items <?php echo $maxwidth; ?>">
<?php query_posts($query); while(have_posts()){ the_post(); get_template_part('inc/parts/item_ep'); } wp_reset_query(); ?>
</div>
本文标签: custom post typesWP queryposts group by meta field related
版权声明:本文标题:custom post types - WP query_posts group by meta field related 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738512674a2090901.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论