Function Signature:
wp_post_mime_type_where
Function Description:
Converts MIME types into SQL.
Function Examples:
⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Retrieve all posts with the MIME type 'image/jpeg'
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image/jpeg',
);
$query = new WP_Query( wp_post_mime_type_where( $args ) );
// Example 2: Get all posts with MIME types 'image/jpeg' and 'image/png' in a specific category
$args = array(
'post_type' => 'attachment',
'category_name' => 'images',
'post_mime_type' => array( 'image/jpeg', 'image/png' ),
);
$query = new WP_Query( wp_post_mime_type_where( $args ) );
// Example 3: Exclude posts with MIME type 'application/pdf' from the query
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'application/pdf',
'post_mime_type__not_in' => true,
);
$query = new WP_Query( wp_post_mime_type_where( $args ) );