Wordpress:通过两个自定义分类法输出自定义帖子类型列表
我需要列出一个自定义的帖子类型,它由这些帖子上的两个不同分类法组织 我有一个自定义的属性/公寓类型,带有位置和类型/大小的分类,我正试图像下面那样列出它们 所需布局 自定义帖子类型 公寓位置 1号公寓Wordpress:通过两个自定义分类法输出自定义帖子类型列表,wordpress,list,custom-post-type,taxonomy,taxonomy-terms,Wordpress,List,Custom Post Type,Taxonomy,Taxonomy Terms,我需要列出一个自定义的帖子类型,它由这些帖子上的两个不同分类法组织 我有一个自定义的属性/公寓类型,带有位置和类型/大小的分类,我正试图像下面那样列出它们 所需布局 自定义帖子类型 公寓位置 1号公寓 清单项目1 清单项目2 清单项目3 2号公寓 清单项目4 清单项目5 清单项目6 公寓位置2 1号公寓 清单项目7 清单项目8 清单项目9 2号公寓 清单项目10 清单项目11 清单项目12 我正在使用当前的代码,但它只是在每个分类大小下吐出所有内容?我无法让它按位置和大小进行过滤
<?php
$terms = get_terms('apartment_location');
foreach( $terms as $term ):
?>
<h2><?php echo $term->name;?></h2>
<?php
$posts = get_posts(array(
'post_type' => 'apartments',
'taxonomy' => $term->taxonomy,
'term' => $term->slug,
'nopaging' => true
)); ?>
<?php
$terms = get_terms('apartment_type');
foreach( $terms as $term ):
?>
<h3><?php echo $term->name;?></h3>
<?php
$posts = get_posts(array(
'post_type' => 'apartments',
'taxonomy' => $term->taxonomy,
'term' => $term->slug,
'nopaging' => true
)); ?>
<?php foreach($posts as $post): setup_postdata($post); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br>
<?php wp_reset_postdata();?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php wp_reset_postdata();?>
<?php endforeach; ?>