【发布时间】:2017-11-02 06:38:05
【问题描述】:
我正在尝试渲染 wordpress 中的类别,以充当我的投资组合的同位素过滤器。
我已开始以下操作,但无法渲染任何内容
<div class="filter-container isotopeFilters2">
<ul class="list-inline filter">
<?php $categories = get_the_category($post->ID);
$count = 0;
foreach($categories as $cd):
$count++;
if($count == 1){ ?>
<li><a href="#" class="active" data-filter="*">All</a></li>
<?php } else { ?>
<li><a href="#" data-filter=".<?php echo $cd->slug; ?>"><?php echo $cd->slug; ?></a></li>
<?php } ?>
<?php endforeach; ?>
</ul>
</div>
【问题讨论】:
-
我很久没有真正使用过 wordpress,但对我来说,您似乎没有得到所有类别,而是分配给特定帖子的类别?
-
@deadfishli 没错,@Neil 请使用此功能
get_categories。
标签: wordpress filtering jquery-isotope taxonomy