// This alters the get get_terms() arguments and hides some categories
function widget_category_excluder( $args ) {
// Replace the numbers with category IDs you need hidden
$args[\'exclude\'] = $args[\'exclude\'].\',1,2,3,\'; // Keep it safe!
// Or use exclude_tree to exclude children categories also
// $args[\'exclude\'] = $args[\'exclude\'].\',1,2,3,\'; // Keep it safe!
// (,1,2,3, is enclosed in \',\' to ensure digits don\'t get welded)
// Test and see what fits your needs best
return $args;
}
// This allows hooking into WP_Widget_Categories and excluding Terms
add_filter( \'widget_categories_dropdown_args\', \'widget_category_excluder\' );
add_filter( \'widget_categories_args\', \'widget_category_excluder\' );
将此代码添加到
functions.php 和实验。这是一个快速解决方案。更好的替代方案是一个可以隐藏类别的自定义小部件。
当做