You can either make use of get_children
or get_posts
or even WP_Query
to get the the attached image ID’s to the current post
You can then use those ID’s to gt the attached image with wp_get_attachment_image()
Here is a basic idea that you can use in a widget or sidebar. (CAVEAT: Untested)
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => get_queried_object_id()
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo '<li>';
echo wp_get_attachment_image( $attachment->ID, 'full' );
echo '<p>'; echo apply_filters( 'the_title', $attachment->post_title );
echo '</p></li>';
}
}
Related Posts:
- Print Current Post Index number within Loop
- what types of order can I pass to get_posts() via orderby?
- rewind_posts() – what actually the use of it, and where using is required or preferred?
- media_handle_upload for local files?
- How to show list of posts by author and category?
- How do I detach images from posts?
- Override the default number of posts to show for a single loop?
- Replacing all attachment links in post with media file link
- WordPress Number of Posts Not Changing With posts_per_page
- Find most recent authors
- Get the author of the latest revision
- Strange switch_to_blog() issue
- Multiple loops in same page, without duplicate content
- loop not displaying posts on custom template page
- How to Display Post View Count
- Displaying the number of posts in a custom loop (without including the number of posts of a loop below)?
- The correct way to call posts with ajax
- custom wordpress post loop – hide iframe content
- Converting multiple loops into one single loop with pagination
- How would I get 1 latest post from a query for 5 posts?
- Alternating post layout
- Check to see if specific loop has less than certain amount of posts
- How to access featured image?
- Avoid duplicate post from same Taxonomy
- Adding specific post category between posts in loop
- Best way to assign post position in a news site homepage? (no categories, no sticky posts)
- How do I restart my loop with get_next_post()?
- Multiple loops are not reset
- Add the description field on the attached media
- Exclude category from
- Blog post per page setting conflicting with custom WP_Query?
- Set size for attachments
- How to exclude latest x posts from a paginated query?
- I have a site where attachments in the wp_posts table have guid values of guid, how did this happen?
- Pausing and Resuming WP_Query results
- Post Loop Missing Most Recent Post
- How to : pagination in 3 different custom loops on the same page
- Sharing post from archive page (loop) doesn’t work
- Automatically attach image to post if they have the same title
- How many posts does the loop return?
- Display Posts on Custom Page
- Multiple Loops Breaking Pages
- Change all author links in Blog roll
- Showing categories and subcategories with posts
- older blog posts not showing in new theme
- The_excerpt() doesn’t parse – how to change that?
- Trying to edit archive.php to only show post extract, with featured image
- How to only publish posts with image in it
- WordPress Query Posts From Category Post on Static Page
- Extracting relevant tags associated with that particular single post only
- Loop through posts? Want to remove extra newlines in actual post HTML/content on backend
- WP_Query: Show 10 posts in date order, first three random
- How include css class based on post ( in loop ) slug?
- WordPress Loop: How to display recent posts in multiple divs
- Show posts by quarter
- Cannot implement byline into posts container in single.php
- Optimizing the blog loop
- How to check if there are posts with the same tag
- Accessing Post ID Within Loop
- Different number of posts per row in grid layout
- linking to post outside the loop
- WP_Query of Category Not Showing First Post
- Cant’ Grab WordPress Built-in Posts Through Loop
- How come this loop is not working? [closed]
- How To Download WordPress Audio Attachments
- Pagination for normal (standard) posts on a page with a custom loop?
- Using the loop to set locations for all posts on a single google map
- Defining ‘last’ class on foreach blog posts
- Want to change the post every three days with in specific category
- Separate top level categories on archive-product.php by meta
- While loop in functions.php outputting the_title() of each post on frontpage
- Shortcode for Comments and Comment Boxes in Post Loop
- Permalink Short code showing unnecessary link text inside the loop
- How can I get the last post while on the first post for pagination? As if it were infinite
- Unable to get all the Posts Attachments
- Double loop output
- post->ID displays the same ID number for every post
- Posts are not showing up on next page.
- List Authors For Current Category
- Post are not showing up
- How to make post button to a random post
- Advanced Post Display/Pagination/Ordering
- Keep post format class with isotope filter
- Make assigning post to a specific category equivalent to assigning it to all categories
- How to inject a post within a loop
- Bulk Attach Or Insert Media To Post Without Opening Post Editor
- Displaying posts on Homepage
- Where are my posts linked to? I keep getting a Not Found Error, and I have no single.php page
- Sort by category and then date?
- Loop not allowing infinite scroll after post per page limit
- Customise the appearance of 4 specific post ID’s within the loop?
- what template-part to call, to have my post in the center of the page?
- Create post from form with image
- The post order is different for logged-in and non-logged-in users? [closed]
- How to show only the date, the title and a little “summary” of my WordPress post in my custom theme?
- How do I create a template page to show 3 blog posts?
- posts_per_page – Repeats only first posts ‘post__in’ array
- blog post displaying within older post – loop issue?
- CSS code for “inserting a custom post divider” after each post
- Broken images after importing posts and opening in Gutenberg