The documentation for the wp_list_categories
filter says that it:
Filters the HTML output of a taxonomy list.
So it filters the final HTML, not the args, but you’re returning $args
, which means that the final HTML is replaced with the args array. That’s why you’re seeing “Array”.
To filter the args for the categories list in the Categories widget, you need to use the widget_categories_args
filter.
function cat_list_show_all( $args ) {
$args['show_option_all'] = __( 'All Cateogries', 'textDomain' ) . '<span>' . wp_count_posts()->publish . '</span>';
return $args;
}
add_filter( 'widget_categories_args', 'cat_list_show_all' );
However, be aware that this filter only works for the “legacy” Categories widget. Newer sites will only have access to the Categories block. The Categories block does not have an equivalent filter, so filtering the args is not possible.