我试图从特定的父类别中检索一些自定义帖子类型。
<div class="tab-content">
<?php
$cat_menu = get_categories(\'taxonomy=menu_categorie&type=menus\');
foreach($cat_menu as $menu) {
echo \'<div role="tabpanel" class="tab-pane active fade" id="\'.$menu->slug.\'">\';
$id = (int) $menu->cat_ID;
$args = array(
\'post_type\' => \'menus\',
\'post_status\' => \'publish\',
\'cat\' => $id
);
$recipes = new WP_Query($args);
if($recipes->have_posts()) : while($recipes->have_posts()) : $recipes->the_post();
echo the_title();
endwhile; endif;
echo \'</div>\';
}
?>
</div>
如果我在数组$args中删除键“cat”,它会工作,但会输出我的所有菜单。我想要的是能够从category\\u id输出我的菜单帖子类型,但我没有显示任何内容。所以我猜$配方中什么都没有,然后就失败了。在检索具有特定类别id的自定义帖子类型时,我是否遗漏了什么?