我有一些海关邮政类型,我已经为这些标签创建了海关分类。
例子:
自定义帖子类型:菜单
自定义分类:参考、价格
基本上我想按自定义帖子类型检索所有帖子(获取所有菜单),但按分类排序(按参考)
<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
非常感谢