I’ve spent hours of research and found the solution a few minutes after writing this question:
$args = array(
'post_type' => 'attachment',
'post_status' => 'inherit', <<-- IMPORTANT
'meta_query' => array(
array(
'key' => 'medientyp',
'value' => 'Video'
)
)
);
$query = new WP_Query($args);
Related Posts:
- WordPress altering my custom query, How to fix it?
- How to make Meta Query case sensitive?
- Get attachment by meta_key value
- Fetch Record based on meta key dates
- how to make members list directory through wordpress post custom meta key.
- Large AND OR query timing out
- How do i create a custom post query when the meta value is an array?
- Trouble with serialized metadata
- Query against multiple locations within single custom post type post
- Can wp_query return posts meta in a single request?
- Use REGEXP in WP_Query meta_query key
- Meta query with string starting like pattern
- compare meta_query in get_posts arguments
- meta_query where value is equal to given value
- querying with custom meta field with meta_query
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- What is an efficient way to query based on post_meta?
- WP_Query not working as expected for attachments and custom meta_query
- How can I create a WP_Query that returns posts where one meta_value
- WP Meta Query for some meta (array) values
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- Order by meta_key in custom post type doesn’t affect the query
- meta_key and meta_value not working together
- Order posts by meta value and Date
- Order Posts by meta value AND published date
- Get meta info related to current post
- Group WP_Query by meta_key date
- exclude posts with a specific custom field and value
- How to do meta_query for attachments?
- Performance when getting post meta for post retrieved by meta value
- Display custom field meta outside loop, site wide
- Meta_query with multiple keys and multiple values
- meta_query BETWEEN, but the range is stored in the custom field
- Where to put meta Keys
- Extend product search with meta in WooCommerce
- meta_value_num not ordering all items
- meta_compare not comparing whole integer
- Is it possible to retrieve all posts with a certain value for metadata?
- Filter posts by comparing custom meta value against postdate
- Display posts with specific value first in query
- Get every post with value in meta key
- Order WP_Query results by meta key value in custom query
- Nested array issue in meta_query
- Display post meta conditionally based on it’s value
- add_query_arg to compare and display events from a certain date
- Comparing 2 Decimal Numbers from custom fields and displaying posts
- Query posts by searching for a string in a meta field
- WP_Query meta compare must include ALL array values
- meta_query weird behaviour, static int will work, but not user data
- Query multiple post types, but different order for each
- Order by the first array within a meta_query
- Query ACF relationship field – Comparator IN – Value array
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- wp query to use both author id and meta_query
- WP Query – grouping posts by same meta key, adding together values from another key
- Meta query ignores multiple values of the key
- meta_query is overriding default search
- show most viewed post
- Comparing Meta Field date in WPQuery using Meta_Query?
- Why can my filter query SOME metadata but not other metadata?
- Getting posts by custom field value
- WP_Query, ACF field and array
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- Order by Date Custom Field
- Query by meta value (add a dropdown of all values)
- Order Posts By Custom Field That is an array of objects
- Saving custom fields for WP_Query to retrieve
- Meta key in wp_query bug?
- Custom WP_query and integrating into theme file
- How to show all the associated posts with specific date of data metabox?
- WP Meta Query at depth 2
- Using custom field as ‘orderby’ value causing post grouping by publish date
- WP_Query Posts by Metadata from Option Tree
- Compare meta key separation
- Sorting Posts with meta value not working
- Return a single custom post from multiple meta queries
- Custom Search Query – include only custom fields and title
- query post based on comparison
- Querying meta values within an array
- Get posts by meta value except one post [closed]
- WP_Query by meta key not returning any posts
- Extend search query to search meta keys values based on search string
- Meta_query compare operator explanation
- Query Multiple Post types each with own meta query
- Query two post types and order by two different date fields
- WP Query – Get WooCommerce Products with variation that is in stock
- Add quicklink to in the Admin posts page where I can query by a meta_key
- Tax query AND/OR meta query [duplicate]
- Custom query filter by ACF date custom field
- Order a WP_Query by meta value where the value is an array
- Sorting posts by Multiple custom fields in defined order
- meta_query – check for multiple meta values in key which holds an array of values
- Searching for a specific month in a metadata saved as Timestamp (Wp_Query)
- Show posts from WP Custom Post Type selected from a field in a metabox
- WP_Query on custom key and value
- How To Query All Attachment Images Found In Post Galleries
- WordPress meta_query not working
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts