WordPress的 - 回声范畴,蛞蝓环
问题描述:
我想呼应多个catgory,蛞蝓,而不是在一个WordPress环路的分类名在archive.phpWordPress的 - 回声范畴,蛞蝓环
我的代码看起来是这样的,我尝试了很多到目前为止,但似乎没有任何工作。所有我实现了接收一个类别的第一毛坯,但不是所有的人:
<li class="<?php the_category(' '); ?> ">
<div class="content">
<h4><?php the_title(); ?></h4>
</div>
</li>
答
下面的代码应该工作
<?php
$categories = get_the_category();
$cls = '';
if (! empty($categories)) {
foreach ($categories as $cat) {
$cls .= $cat->slug . ' ';
}
}
?>
<li class="<?php echo $cls; ?> ">
<div class="content">
<h4><?php the_title(); ?></h4>
</div>
</li>
像一个风情万种!非常感谢你! – Nic