【发布时间】:2016-04-08 18:50:23
【问题描述】:
我已经注册了一个自定义帖子类型“项目”,并且还为该帖子类型注册了一个名为“项目类别”的自定义分类。在我的主页上,我有一个 div,我想在其中列出“项目类别”分类中的所有项目和术语。目前,我只能获取条款列表。有人可以告诉我为什么我无法显示这些条款。目前,我有:
<div class="list-container">
<?php
query_posts( array( 'post_type' => 'projects' ) );
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; wp_reset_query(); ?>
<?php $taxonomy = 'project_categories';
$tax_terms = get_terms($taxonomy);
?>
<?php foreach ($tax_terms as $cat): ?>
<li><?php $cat; ?></li>
<?php endforeach; ?>
</div><!--end list-container-->
我的另一个问题是,将分类法包含在 query_posts 循环内部还是外部更好?
【问题讨论】:
-
你在这里错过了回声
标签: php wordpress loops custom-post-type