category.php页
<?php
// 获取全站分类名称和url(分类中必须含有文章,否则不显示)
$args = array(
‘orderby’ => ‘ID’,
‘exclude’ => ‘1’, //排除的分类ID,以英文逗号分隔开
‘order’ => ‘ASC’
);
$categories = get_categories($args);
foreach ($categories as $category) {
echo ‘<li style=”z-index:2;” class=”wp_subtop” pid=”1″><a class=” ” href=”‘ . get_category_link($category->term_id) . ‘”>’ . $category->name . ‘</a></li>’;
}
?>
taxonomy
<?php
// 获取全站分类名称和url(分类中必须含有文章,否则不显示)
$args = array(
‘orderby’ => ‘ID’,
‘exclude’ => ‘1’, // 排除的分类ID,以英文逗号分隔开
‘order’ => ‘ASC’,
‘taxonomy’ => ‘news_list’ // 自定义文章类型
);
$categories = get_categories($args);
foreach ($categories as $category) {
echo ‘<li style=”z-index:2;” class=”wp_subtop” pid=”1″><a class=” ” href=”‘ . get_category_link($category->term_id) . ‘”>’ . $category->name . ‘</a></li>’;
}
?>