0
我已經使用下面的代碼來顯示最近的類別<?php wp_list_categories('title_li=<h3>' . __('Recent Categories') . '</h3>'); ?>
。我需要從顯示中排除一些類別。我怎樣才能做到這一點?wordpress最近類別小部件
我已經使用下面的代碼來顯示最近的類別<?php wp_list_categories('title_li=<h3>' . __('Recent Categories') . '</h3>'); ?>
。我需要從顯示中排除一些類別。我怎樣才能做到這一點?wordpress最近類別小部件
您可以嘗試使用「get_categories」。這有點複雜,但更靈活。您可以通過在參數中包含逗號分隔的類別列表來排除具有此功能的特定貓。請看下圖:
$args=array(
'orderby' => 'name',
'order' => 'ASC',
'exclude' => '1,4,9' <--- Add your cats to exclude here
);
$categories=get_categories($args);
foreach($categories as $category) {
echo '<p>Category: <a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . '>' . $category->name.'</a> </p> ';
echo '<p> Description:'. $category->description . '</p>';
echo '<p> Post Count: '. $category->count . '</p>';
}
瞭解更多關於get_categories在http://codex.wordpress.org/Function_Reference/get_categories >
?