我想在列表中显示空类别。此代码有什么问题?
function cat_list(){
$args = array(
'hide_empty' => 0,
'orderby' => "name",
'order' => "ASC" );
$categories = get_categories(args);
foreach($categories as $category){
echo '<li><a href="' .get_category_link($category->term_id) . '"> '. $category->name . '</a></li>';
}
}
答案 0 :(得分:0)
在将参数传递到$
时,您缺少get_categories
。这是固定的。
function cat_list(){
$args = array(
'hide_empty' => 0,
'orderby' => "name",
'order' => "ASC" );
$categories = get_categories($args);
foreach($categories as $category){
echo '<li><a href="' .get_category_link($category->term_id) . '"> '. $category->name . '</a></li>';
}