The WP_Query documentation on the codex specifically says:
‘attachment’ – an attachment. Whilst the default WP_Query post_status
is ‘publish’, attachments have a default post_status of ‘inherit’.
This means no attachments will be returned unless you also explicitly
set post_status to ‘inherit’ or ‘any’.
I am not sure why it was working before because this is not a recent change but it looks like post_status would have to be ‘inherit’ or ‘any’ rather than null.
Related Posts:
- How to build a WP_Query using mulitple tags and using AND or OR operator between them
- Display posts from only one post form in custom query and exclude in main query
- Filtering out child category posts from parent category archive not working
- Get posts that do not have the same tags as current
- Filter products on category AND tag
- How do I stop the same post showing multiple times in a archive?
- Get posts that match defined arrays of tags
- WordPress custom query by archive title
- When should you use WP_Query vs query_posts() vs get_posts()?
- When to use WP_query(), query_posts() and pre_get_posts
- Get post ids from WP_Query?
- Nested meta_query with multiple relation keys
- Broken? WP_Query and “attachment” as a post type
- Some doubts about how the main query and the custom query works in this custom theme?
- Wp get all the sub pages of the parent using wp query
- Posts with at least 3 tags of a list of tags
- How to query for most viewed posts and show top 5
- WP Query where title begins with a specific letter
- WP_Query vs get_posts
- Is it possible to query all posts that don’t have an attachment?
- How to paginate wordpress [gallery] shortcode?
- Using OR conditions in meta_query for query_posts argument
- Query Posts in a Predefined Order
- Order posts by ID in the given order
- How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?
- Better way to get tag stats?
- Getting attachments by meta value
- Count the number of images uploded on the website
- Query Multiple Post types each with own meta query
- How to paginate attachments in a secondary query as gallery?
- Get posts by menu ID
- $wp_query initiation?
- Get the number of posts from the current page results
- Given a WP_Query, how can I get a list of tags?
- Executing Queries in tag.php
- WordPress Custom Query to show posts from last x years
- How to order posts tag by tag?
- Query Custom Meta Value with Increment
- post_type is ignored by WP_Query when ‘tag’ argument is included
- How do I exclude all images from a wp_query?
- WP Rest API v2 return posts with specific tag
- How to know which one is the main query?
- Loop through all tags & output posts in alphabetical list
- Get posts by meta data OR title
- get images attached to post
- Perform query with meta_value date
- Using is_main_query to select custom post type on certain page
- WP_Query ordered by custom field that is a date string?
- get query’s query string
- Meta Query with date and time on the same Day before given time
- get_the_title($postID) OR get_the_title()?
- Display Posts by modifying the where clause only for my query
- Order posts by tags count?
- Custom archive page based on array of categories and tags
- How to create an attachments archive with working pagination?
- How do I create my own nested meta_query using posts_where / posts_join?
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- Best practice for multiple queries on page
- How to Get All Posts but the Private ones?
- Get attached media only
- How to get any tag ID
- Filter query_posts by tag slug on “Tag Archive” page (when tag is 2 or more words)
- Get all posts without tags
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- How to query ‘posts_per_page’ to display a different blog posts index template?
- How to find out what “Blog pages show at most” is set to [duplicate]
- Multiple search queries on one page
- query attachments of parent page if attachments of current page are smaller than …
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- Pass the same object to multiple widgets in a template with one query
- Retrieve or Query Pages by ID
- WP query exclude post within the last month / only show over 1 month old
- WordPress query for most recent posts from multiple categories
- How do you query wordpress posts using a math formula between multiple meta field values?
- How add a custom posttype name using ACF field to a query post array
- How to exclude products by tag from woocommerce shop page?
- wp_query for displaying attachments with a tag
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Pagination problem after WP_Query with tag filtering
- Too many posts cause slow load when paginating
- Page navigation doesn’t show when query category
- Multiple instances of Featured Image Query
- How can I pick a single post from the latest 3?
- 2 loops on page – one with orderby rand second orderby date
- Show selected images on top in Media Manager
- How do you Query posts with nothing in common?
- Query post with meta_query where date is not in future
- Next/Prev posts on same page
- How can I query posts with newly uploaded images?
- Tell wordpress to show a single page instead of an archive
- Custom category search box for WordPress
- Sorting By Custom Posts With Attachments
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- Query post from all category with same tag on 1 pages
- Attachment changing page’s permalink – $post not resetting?
- Query with custom taxonomy not working
- Query posts by specific word on title
- How to query a custom post type with a taxonomy filter but display post type archive page?
- reducing the amount of wp_query calls
- How to fetch only media that was already attached to a post/page?