我有一些海关职位类型,我为这些标签创建了海关分类。
例如:
自定义帖子类型:菜单
自定义分类:参考,价格
基本上我想通过自定义帖子类型检索所有帖子(获取所有菜单),但按分类法排序(通过参考)
<ul>
<?php
$args = array(
'public' => true,
'_builtin' => false
);
$output = 'objects';
$post_types = get_post_types($args, $output);
foreach ($post_types as $post_type) {
?>
<li>
<a href = "<?php echo $uploads['url']; ?>/Appetizers.jpg"><?php echo $post_type->label; ?></a>
<div class = "ac_subitem">
<span class = "ac_close"></span>
<h2><?php echo $post_type->label; ?></h2>
<ul>
<?php
$loop = new WP_Query(array('post_type' => $post_type->name));
while ($loop->have_posts()) : $loop->the_post();
?>
<li>
<?php
$reference = wp_get_object_terms($post->ID, 'references');
foreach ($references as $reference) {
echo ('<span class="reference">');
echo $reference->name;
echo (' .</span>');
}
$price = wp_get_object_terms($post->ID, 'price');
foreach ($prices as $price) {
echo ('<span class="price">');
echo $price->name;
echo ('</span>');
}
endwhile;?>
</li>
</ul>
</div>
<?php
}?>
</li>
</ul>
输出应为:
参考文献1 - 价格£5.00
参考2 - 价格£3.00
参考3 - 价格£6.00
非常感谢