我创建了简单的自定义帖子类型,几乎没有分类法。我
<?php $query_params = getQueryParams(); $query_params[\'post_type\'] = \'client\';
if(isset($query_params[\'search\'])){
$query_params[\'post_title_like\'] = $query_params[\'search\'];
unset($query_params[\'search\']);
}
$loop = new WP_Query($query_params);
if($loop->have_posts()) : while($loop->have_posts()): $loop->the_post();
// SOME HTML
endwhile; endif; ?>
然后,我尝试列出每个帖子的显示分类法,如下所示:
$categories = get_categories("taxonomy=city");
foreach ($categories as $category) :
echo \'<li>\' . $category->name . \'</li>\';
endforeach;
但我总是得到所有创建的分类法,而不仅仅是选择发布。有什么建议吗?