I'm trying to hide a large amount of categories from my category widget. I've tried a few plugins but none of them seem to want to let me use the dropdown option. I looked into the widget_categories_args hook and that seems to be what I want but I can't get it to work.
Anyways here's my code
function widget_categories_args_filter( $cat_args ) {
$exclude_arr = array( 57,61,63,56,55,62,52,53,54,67,65 );
if( isset( $cat_args['exclude'] ) && !empty( $cat_args['exclude'] ) )
$exclude_arr = array_unique( array_merge( explode( ',', $cat_args['exclude'] ), $exclude_arr ) );
$cat_args['exclude'] = implode( ',', $exclude_arr );
return $cat_args;
}
add_filter( 'widget_categories_args', 'widget_categories_args_filter', 10, 1 );
I Took that from here: https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_categories_args
I'm putting this in my theme's functions.php. That shouldn't matter even though the function is set for plugins, right?
1
. Try1000
. As I said, this works for me so there may be another function interfering. Setting the priority high might give yours the last word. Are you using the Core category widget?