我很绝望。具有双重分类“过滤”的自定义文章类型
我想要一个名为“ff_awards”的自定义帖子类型的存档页面。有两种自定义分类称为:游戏,seeson。
- 交类型:ff_awards
- 分类1:fh_game/GAME
- 分类2:fh_seeson/SEESON
这里是我尝试实现模型:
游戏1
- Seeson 1
- 所有岗位在第一场和Seeson 1
- Seeson 2
- 所有岗位在第一场和Seeson 2
- Seeson 1
游戏2
- Seeson 1
- 所有岗位在第一场和Seeson 1
- Seeson 2
- 在第二场比赛和Seeson 2
- Seeson 1
所有文章中,我尝试几乎所有的东西。下面是我的实际代码,这工作不仅在模式:
- 游戏1
- 所有岗位在比赛1
也正在这种模式:
Seeson 1
所有岗位在Seeson 1
<?php //for a given post type, return all $post_type = 'ff_awards'; $tax = 'aw_game'; $tax_terms = get_terms($tax); if ($tax_terms) { foreach ($tax_terms as $tax_term) { $args=array( 'post_type' => $post_type, "$tax" => $tax_term->slug, 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if($my_query->have_posts()) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <div> hero goes post</div> <?php endwhile; } wp_reset_query(); } } ?>
非常感谢你。
不,这个代码工作,我提到它上面,而只是1个分类。代码仅用于说明我已完成的工作。但是我需要添加更多的代码,以适应两种分类。 – MarsShalL 2014-08-28 17:56:41