You can use 'post_type' => 'any'
if you are not sure of the post types resulting from other query arguments.
According to documentation that is what happens by default when you use tax_query
:
post_type (string / array) – use post types. Retrieves posts by Post Types, default value is
'post'
. If'tax_query'
is set for a query, the default value becomes'any'
Outside of WP_Query
context you would probably need to get such information from global $wp_taxonomies
array, which track taxonomies and post types they apply to.