The widget class uses wp_list_categories()
which supports all the parameters for get_terms()
like taxonomy
which you can use to make the widget lists categories in a taxonomy other than category
.
So your code would be:
add_filter('widget_categories_args', function( $params ) {
// $params['post_type'] = array('post', 'recipe'); // post_type is not a standard parameter for get_terms()
$params['taxonomy'] = 'recipe-categories';
return $params;
});
However, the widget only supports a single taxonomy because wp_list_categories()
uses taxonomy_exists()
which doesn’t support multiple taxonomies. Here’s the relevant code in wp_list_categories()
which causes the limitation:
if ( ! taxonomy_exists( $parsed_args['taxonomy'] ) ) {
return false;
}
So if you want to use multiple taxonomies, then you’d need a plugin for that (i.e. one that provides a similar widget) or you can code your own widget class.