我似乎无法显示子类别列表的描述。到目前为止我有这个
<?php
$subcategories = get_categories('&child_of=5&hide_empty');
foreach ($subcategories as $subcategory) {
echo '<div style="position:relative;float:left;width:100%;margin:0 0 20px 0;border-bottom:1px dashed #cdcdcd;padding:0 0 20px 0">';
echo sprintf('
<a class="newstitle" href="%s" style="margin:0">%s</a>', get_category_link($subcategory->term_id), apply_filters('get_term', $subcategory->name));
echo '<br /><br />';
echo '</div>';
}
?>
这会使用正确的链接列出子类别的标题,但我似乎无法在两个换行符下显示说明。
由于
答案 0 :(得分:1)
你应该尝试类似的东西。
<?php
$subcategories = get_categories('&child_of=5&hide_empty');
foreach ($subcategories as $subcategory):?>
<div style="position:relative;float:left;width:100%;margin:0 0 20px 0;border-bottom:1px dashed #cdcdcd;padding:0 0 20px 0">
<a class="newstitle" href="<?php echo get_category_link($subcategory->term_id) ?>" style="margin:0"><?php echo apply_filters('get_term', $subcategory->name) ?></a>
<div class="cat-desc">
<p>
<?php echo category_description($subcategory->term_id); ?>
</p>
</div>
<br /><br />
</div>
<?php endforeach ?>