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 to use WP_query(), query_posts() and pre_get_posts
- Nested meta_query with multiple relation keys
- WP_Query vs get_posts
- Using OR conditions in meta_query for query_posts argument
- 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()?
- Query Multiple Post types each with own meta query
- Get posts by menu ID
- Get the number of posts from the current page results
- post_type is ignored by WP_Query when ‘tag’ argument is included
- How to know which one is the main query?
- get query’s query string
- Meta Query with date and time on the same Day before given time
- Order posts by tags count?
- How to create an attachments archive with working pagination?
- Filter query_posts by tag slug on “Tag Archive” page (when tag is 2 or more words)
- Multiple search queries on one page
- 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
- Page navigation doesn’t show when query category
- 2 loops on page – one with orderby rand second orderby date
- Custom category search box for WordPress
- How to fetch only media that was already attached to a post/page?
- Query with a meta value inside a given range
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- Five posts from a category in footer
- Remove category from query (show all posts in archive.php) pre_get_posts()
- How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
- How to display multiple custom fields with the same meta_key in an ascending order?
- new WP_Query(), have_posts() return false in user_register hook
- How to show optimized list of posts with all their attachment images
- Query posts intersecting tags and categories
- Some doubts about how the main query and the custom query works in this custom theme?
- How to display an other custom post type in a different custom post type’s archive?
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- How to increase load time of an archive/search page (WP_Query)
- Query Page Content From Theme Options?
- Query all posts if multiple meta key don’t exist
- Order by most used tag
- WP Query with multiple tags by get the tags
- Exclude All Posts Which Do Not Have A Tag Assigned
- Include current post into loop
- Easy way to write complex queries in wordpress
- get_posts output always same post
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- complex get_posts() query to select child pages
- Posts Query | Query to only show sub categories
- How do I add a relation parameter to my filter query?
- wp_query get attachments in larger size
- Get next/prev image/attachment in time with date query
- Show single posts date, in a page of posts
- Post archive for certain post format
- specific post is not excluded from the loop
- Why doesn’t my WP Meta Query return any results?
- Paginate pages with dynamic query
- Trouble Making WP_Query paged
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Determine if ID is page or post and query the ID
- Custom template for password protected page
- WP_Query Class custom field parameters
- Add AJAX “Load more” on custom query block
- Optimising WP_Query with ACF Fields
- Elementor posts custom query based on tag [closed]
- get_children() Archive Template
- In a WP_Query can I force the results’ is_singular() to be set to false?
- Facing problem with tax_query results
- How to restrict add media library only to images of the same post family?
- Order posts by tags count?
- how to get custom attachment url?
- trying to change from query_post to WP_Query
- I need query_posts() to order results first by a meta value and then by post ID
- getting posts by tags
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- How to search CPTs in draft using get_page_by_title()
- Show posts from categories instead of tags
- Orderby query does not work for custom fields even with meta query
- Custom WP_query and integrating into theme file
- query_posts() doesn’t seem to be called in my page
- Some doubts about how the main query and the custom query works in this custom theme?
- Fetching $_POST from Page Template into functions.php
- How to allow Readers to Select Post Order?
- Random posts in WP_Query when searching by tag
- Query All Attachments and Order by Parent Publish Date
- How To Query All Attachment Images Found In Post Galleries
- Ordering Posts by parent category, name ascending
- Optimising specific Query with ACF meta objects
- query_posts with sorting on a custom datestamp
- query post based on comparison
- Query Posts by date range with fixed beginning and end
- Multiple loop for “featured” items returns wrong posts
- Having trouble using this post category query on multiple pages?
- query_posts problem – need help