You can use get_posts()
(Codex ref for getting Post attachments).
<?php
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
);
$attached_images = get_posts( $args );
?>
Related Posts:
- How do I sort (order) the results from `get_children()`?
- How to create a template for Pages?
- Give posts a particular template based on the assigned category
- How to Featured content with images in home page?
- Aligning images in the wp editor not working. How do i get this to work in custom theme?
- Integrate video and iframe in a post type gallery
- Which hooks are essential for post templates?
- Is there a block to print post link standalone in a block theme?
- How to display the link (title) and thumbnail post?
- Underscores Theme Unit Testing – Catching Untitled Posts
- get_the_excerpt() is not working as expected – returns wrong text
- I have a site where attachments in the wp_posts table have guid values of guid, how did this happen?
- CSS: How can I show a photo beyond the template’s column, but contained within the browser window? [closed]
- Get all attachment by post excluding featured and content inside
- How to use format post in a pertinent way
- wp-cli post create & media import issues
- Switch to page template when using post permalink
- Unable to restore from backup – how to obtain old blog posts?
- Get attachments for posts that belongs to a specific category
- Genesis + Ajax + Jquery | Failling to call action
- List all categories with featured image from post?
- Get Page ID of blog homepage
- Send post id through ajax and get the post content back
- Get all images in post and comments like Twitter before post title
- custom post template file not shown, instead all the time 404.php
- Disable sticky option for specific categories
- Show only posts with images and a fixed amount of posts
- Issue where WP Featured Image will not display
- How would one change the default url structure of attachments?
- Highlight static blog page link in header
- How to create new post content templates for my users?
- Redirect to another page using contact form 7? [closed]
- How do I stop the loop from repeating in my category template?
- If statement to check if post has image
- How do I do a page break?
- Gather posts into a cart/lightbox and share with another user
- posts not showing on index.php
- Thumbnail Image to go in the post aswell
- Block editors annoying warnings
- Remove Featured Image & All Media Uploaded to the Post
- What does WordPress do if I save a post without content/title? [duplicate]
- Hide a specific post from a page template
- How to add a class to edit_post_link?
- What are the benefits of setting a “featured image” for a WP blog post?
- Tell WP to use a specific template file in posts
- Admin – no Featured image choice in create new/page|post
- Is there a way to create a meta box that can be added multiple times to a post dynamically?
- preg_replace not removed “class”
- How to make different custom post layouts?
- update image path with words starting uppercase to lowercase chars
- How to only publish posts with image in it
- Why won’t pagination work?
- Uploading images in custom post form
- Upload attachment from external site
- Is it possible to give the user the chance to select between two single template files to use in a post?
- Make insterted image point to post url instead of attachment page
- Create a custom posts page
- how to set social icons to product / post template (Auros theme)? [closed]
- How to identify and hide/remove an element from a WordPress page [closed]
- wordpress posts template remove default template from menu
- Get URL from all images in a post
- how to hide empty fields of post category description?
- Disable posts generated from image uploads
- Force a specific template as default
- how to give multiple post thumbnails to a post
- Posts page not showing correct image
- Images showing up in Post Editor, but not in Published Post
- How to allow multiple thumbnail upload for Posts?
- showing posts of an specific category in admin custom menu with style of admin posts section
- Image behind the post’s title
- get_children returns older images
- How to display post title inside thumbnail?
- How to remove text and retain in caption image using the_content function
- How to retrieve certain number of images from a wordpress post?
- Display Featured Posts Grid on Static Page (Gazette)
- how to handle the loop using filling bootstrap grid structure?
- Show more than 200 images in one post
- How to get all inline images in post content? [duplicate]
- Display a post via template
- Single post full screen template not inheriting WordPress role permission
- How to set a certain Custom Template to a Single Blog Post
- Hide thumbnail if there is a gallery on the post
- Image on rss feed on post
- Change the background of each post according to the category
- List all native posts in template page?
- Sidebar on single.php not showing up
- Cant’ Grab WordPress Built-in Posts Through Loop
- Change default post style to columns
- Where to insert the other site image url for our wordpress post
- select post preview image from nextgen gallery
- How to show a featured image inside a post in only 1 single category
- Inserting Media to WordPress Posts
- Post Templates and Post ID’s
- Author Avatar as default first image
- How do I allow certain users to make a certain type of post?
- Link post images to post
- How do I disable the “by author” hyperlink on posts?
- Trying to query all posts in category 4
- How to add a post class on every post. (on homepage)
- How to get the next and previous image title from attachment or gallery?