0

我似乎无法显示子类别列表的描述。到目前为止我有这个

<?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>';
 }
?>

这列出了带有正确链接的子类别的标题,但我似乎无法在两个换行符下显示描述。

谢谢

4

1 回答 1

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 ?>
于 2013-08-02T10:38:04.650 回答