Skip to main content
edited tags
Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459
Source Link
Sisir
  • 7.8k
  • 8
  • 60
  • 99

Query all published post AND attachment with specific mime type

I need to add only specific attachments (PDF) to the query along with other CPT. But when I add mime type value to the query any other post type get filtered out.

Here is the query args

$args = [
    'post_type' => ['any', 'attachment'],
    'post_status' => ['publish', 'inherit'],
    'post_mime_type' => ['application/pdf'],
    'posts_per_page' => 10
];

How do I get other post types with attachments of specific mime type? (only pdf in this case)