First of all if any
is used for post_type
field there can not be any other value given in array like in the question. Below is the modified args
$args = [
'post_type' => array_values(get_post_types(['public' => true])),
'post_status' => ['publish', 'inherit'],
'posts_per_page' => 10
];
Use posts_where
filter
add_filter('posts_where', 'add_search_mime_types');
$query = new WP_Query( $args );
remove_filter('posts_where', 'add_search_mime_types');
function add_search_mime_types($where){
$where .= ' AND post_mime_type IN("application/pdf","") ';
return $where;
}
The empty string on the SQL query to include post types other then attachment
.