我绝望了。
我想要一个名为"ff_awards"的自定义帖子类型的存档页面。有两种自定义分类法称为:game,seeson。
- 帖子类型:ff_awards
- 分类法1:fh_game/game
- 分类法2:fh_seeson/SESSON
以下是我试图实现的模型:
-
第一场比赛
-
Seeson 1
- 所有帖子在第一场和Seeson 1
-
Seeson 2
- 在第一场和Seeson 2中的所有帖子
-
Seeson 1
-
游戏2
-
Seeson 1
- 所有帖子在第一场和Seeson 1
-
Seeson 2
- 第二场和Seeson 2中的所有帖子
-
Seeson 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(); } } ?>
-
非常感谢。
我认为您只需要为$args提供正确的语法。看看这个:http://www.billerickson.net/code/wp_query-arguments/
您要了解的内容大约在第32行:这个示例允许您按2个分类术语进行筛选。