wordpress最近的类别小部件

时间:2012-03-05 06:16:08

标签: wordpress

我使用以下代码显示最近的类别<?php wp_list_categories( 'title_li=<h3>' . __('Recent Categories') . '</h3>' ); ?>。我需要从显示中排除一些类别。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

您可以尝试使用'get_categories'代替。它有点复杂,但更灵活。您可以通过在args中包含以逗号分隔的类别列表来排除具有此功能的特定猫。见下文:

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

http://codex.wordpress.org/Function_Reference/get_categories了解有关get_categories的更多信息 ?&GT;

相关问题