These are the query parameters i use…works for me when i loop through the results
array(
'post_parent' => $post->ID,
'post_status' => 'inherit',
'post_type'=> 'attachment',
'post_mime_type' => 'image/jpeg,image/gif,image/jpg,image/png'
);
For more detail, please see official documentation for WP_Query’s status parameters
Related Posts:
- Is it possible to query all posts that don’t have an attachment?
- How to paginate wordpress [gallery] shortcode?
- How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?
- Getting attachments by meta value
- Count the number of images uploded on the website
- How to paginate attachments in a secondary query as gallery?
- How do I exclude all images from a wp_query?
- get images attached to post
- Get attached media only
- query attachments of parent page if attachments of current page are smaller than …
- wp_query for displaying attachments with a tag
- Show selected images on top in Media Manager
- How can I query posts with newly uploaded images?
- Sorting By Custom Posts With Attachments
- Attachment changing page’s permalink – $post not resetting?
- How to fetch only media that was already attached to a post/page?
- How to do meta_query for attachments?
- Get attachment by meta_key value
- How to show optimized list of posts with all their attachment images
- Where to put meta Keys
- WP_Query Attachment adds additional attachment count and need to link attachment to post url
- Why having more than 10 clauses in WP_Query results in some outputs being dropped?
- wp_query get attachments in larger size
- Creating attachments archive in tags and categories
- Ignore image urls in wp_query search
- WP_Query: attachment image in “full” size?
- How can I build a query that returns all attachments of a page and it’s children pages?
- get all images from the wordpress media library with link to the post they are associated with
- How to restrict add media library only to images of the same post family?
- how to get custom attachment url?
- wp_get_attachment_image not to get the post_thumbnaill
- Query All Attachments and Order by Parent Publish Date
- How To Query All Attachment Images Found In Post Galleries
- WP_Query for attachments without duplicating post_parent and displaying tagged image
- Using WP_Query to get attachment returns empty set
- Some images not being returned with wp_get_attachment_image
- Loop issues when creating custom query for media uploader
- Give attachments an archive page, and exclude unattached ones
- on attachment.php, how to display previous and next attachment links that follow the same order as a custom WP Query
- When to use WP_query(), query_posts() and pre_get_posts
- How to get an array of post data from wp_query result?
- How to only display posts whose meta_value field is not empty?
- Meta query with string starting like pattern
- WP Query where title begins with a specific letter
- Query Custom Meta Value with Increment
- Order by two meta keys
- multiple meta key but get server load is very high
- A WP_Query that will look for posts after 2 weeks ago OR with a certain meta value
- Ignore a filter on the media library
- if wp_query taxonomy term have posts
- Pagination broken when merging search results with additional WP_Query
- How to display posts from multiple post type in random order in wordpress?
- How can i get the last post from wp multisite?
- WP_Query, custom sort and custom filter
- Use meta_query to display events by date in custom field
- Calling WP_Query with the same args in two different places produces two different results
- tax_query OR with empty result returns all posts
- WP_Query Order by Specific Post ID First
- Custom Query – show first post twice?
- Next/Prev posts on same page
- Creating query to show which editor (classic or block) was last used to edit a post/page
- is_tax() function not working as expected
- Getting the current post number / make posts increment
- Optional Meta Query
- Set conditional on template based on referring page slug
- Multiple If Else with WP Query in WordPress
- Serve specific “template” page at any URL that ends in its slug
- WordPress pagination not working using WP_Query
- Meta_query on same meta key, with diffrenct values
- posts_per_page not working for first page of pagination
- Add class to first post in custom loop using post_class filter
- echo a specific meta_key queried through a custom post
- WP_Query with meta_query dosen’t return results
- Get latest post revision with wp-query
- How to show more post at a given category?
- Merge two search functions for custom post type
- Filter Custom Taxonomy Posts
- Config.php issue in WordPress
- problems with comments_number()
- Trying to retrieve random post, getting a page
- WP_Query by keyword OR post tag
- query_vars empty when using custom url with custom rewrite rule
- Post archive for certain post format
- Add AJAX “Load more” on custom query block
- Why my query is not “Main_query”?
- Filter sub-category from checkbox form
- How to add a “base” filter for all posts visible to visitors on the site?
- Pagination of custom page with custom fields query
- WP_Query() not filtering posts for category
- wp query search multi terms
- add action for wordpress query at a specific position
- How to query wordpress with array of meta_values?
- Updating an intensive wp_query result once daily
- Filter custom post type by custom taxomony
- Query post Pagination Problem
- An archive page without post format (just standard post)
- Pull Instagram images into an existing loop?
- Pagination showing same posts despite changing page
- Query custom post types by meta field in a term from custom taxonomy
- Display post format post in the sidebar