@Sandun为什么不创建自己的小部件?
<?php
class Category_List_Custom extends WP_Widget {
/**
* Sets up the widgets name etc
*/
public function __construct() {
$widget_ops = array(
\'classname\' => \'category_list_custom\',
\'description\' => \'Category list custom\',
);
parent::__construct( \'category_list_custom\', \'Category List Custom\', $widget_ops );
}
/**
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget( $args, $instance ) {
$cats = get_categories();
$ordered_cats = array();
foreach($cats as $cat){
$ordered_cats[$cat->category_count] = $cat;
}
ksort($ordered_cats);
$return = \'<ul>\';
foreach($ordered_cats as $cat){
$return .= \'<li>\' . $cat->name . \'</li>\';
}
$return .= \'</ul>\';
return $return;
}
}
add_action( \'widgets_init\', function(){
register_widget( \'Category_List_Custom\' );
});?>
它应该与此非常相似。
如果有帮助,请告诉我。