只需添加「黑客」在插件文件中的函數:
function advanced_categories_widget_html($args = array()) {
$args = wp_parse_args($args);
$args['walker'] = new Walker_Advance_Category_Widget;
$cats ='';
$categories=get_categories();
$rand_keys = array_rand($categories, 5); // 5 is the number of categories you want
foreach ($rand_keys as $key) {
$cats .= $categories[$key]->term_id .',';
}
$output = wp_list_categories($args.'&include='.$cats);
if ($output) return $output;
}
或者通過更清潔的方式,加入到functions.php文件中:
function random_advanced_categories_widget_html($args = array()) {
$args = wp_parse_args($args);
$args['walker'] = new Walker_Advance_Category_Widget;
$cats ='';
$categories=get_categories();
$rand_keys = array_rand($categories, 5); // 5 is the number of categories you want
foreach ($rand_keys as $key) {
$cats .= $categories[$key]->term_id .',';
}
$output = wp_list_categories($args.'&include='.$cats);
if ($output) return $output;
}
我加入這個代碼,插件或function.php但我不工作, 我的網站是:http://sayarti16.markedia.info/(側邊欄上的第一小) 的是文件插件:http://codepad.org/a3yU7Xny –