admin管理员组文章数量:1405145
how to edit wp category widget, so it would not show one of specified category? For example, it shows all categories in list, and I need to remove category Books, from it, how can I do it? Best regards, Y2ok
how to edit wp category widget, so it would not show one of specified category? For example, it shows all categories in list, and I need to remove category Books, from it, how can I do it? Best regards, Y2ok
Share Improve this question asked Oct 21, 2011 at 15:06 Y2okY2ok 251 gold badge3 silver badges5 bronze badges1 Answer
Reset to default 0// 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' );
Add this code to your functions.php and experiment. It's a quick fix. A better alternative is a custom widget with the possibility to hide categories.
Regards.
本文标签: categorieshow to edit wp category widget
版权声明:本文标题:categories - how to edit wp category widget 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744886919a2630543.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论