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:
- Some doubts about how the loop work (trying debugging it)
- Custom WP_Query not working correctly
- Different number of posts per row in grid layout
- Optimize CPT-function with a loop
- Display specific posts on home page
- The loop starting at a certain ID
- linking to post outside the loop
- WP_Query of Category Not Showing First Post
- If custom field is empty, use one from a previous post
- Cant’ Grab WordPress Built-in Posts Through Loop
- How come this loop is not working? [closed]
- Loop not showing first post
- Get post category as a separate string and url
- How To Download WordPress Audio Attachments
- Limiting the amount of posts retrieved by the loop
- Display 3 posts with different HTML markup using a loop
- Pagination for normal (standard) posts on a page with a custom loop?
- How to get the next and previous image title from attachment or gallery?
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- I can’t find the relevant part of the loop in my theme file. How do I find the full content with “More…”
- posts going to 2 pages/categories only show up in 1
- How to repeat a loop after 4 posts [duplicate]
- Custom Post Type Single Loop Outputting Wrong Post
- Using the loop to set locations for all posts on a single google map
- How to separate each individual blog post?
- Defining ‘last’ class on foreach blog posts
- Get current taxonomy and display query accordingly
- All images on one line for each post
- How to show full post on home page
- Error while excluding a post from another loop (using its ID)
- Is there a way to define the $post var outside the loop?
- ACF flexible content block not showing on live site (works locally)
- Only the most recent post is showing on my category page (working on localhost, not live site)
- 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 do I assign an attachment to a post using only the REST API?
- Current post categories and subcatecories outside of the loop
- Unable to delete attached file from folder programmatically
- How to convert attachment pages to Posts?
- Multiple post in One Loop in wordpress
- Display specific posts based on an ID of another post
- Numbered Pagination Showing The Same Posts After Altering WP_Query
- “read more” redirects to the wrong page
- Diffrent layout for posts [duplicate]
- How to show post views shortcode data for each post on Posts List Page?
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- Get post attachment with post id
- Count singular post views automatically
- How to distinguish pages created by woocommerce?
- Delete attached images from posts
- Moved a website and excerpts don’t work for old posts
- show loop id post , only first id can read
- 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
- Loop and output 4 rows of posts on home page
- Double loop output
- How to show category image if no featured image is set?
- Get post id outside loop : Notice: Trying to get property of non-object
- how to call recent post content in a loop ( only the content before read more tag)
- Retrieve posts inside foundation tabs and tab-content split by 3 per row
- Loop through all posts showing duplicates
- Can I Paginate Post after every 25 tag?
- Post being duplicated with foreach loop
- Alternative content between posts no repetition
- Start loop from specific post ID
- post->ID displays the same ID number for every post
- Display new posts categories in separated divs
- Show post excerpt
- Add in the url attachment loop the wp_link_pages of the post
- Wp_query loop is not working as it should
- Show author bio box
- Maximum number of posts per page before affecting performance?
- Use special template for the first post in the loop
- Display post order ranking within wordpress loop
- Posts are not showing up on next page.
- Can the_post_navigation() be outside of the loop?
- Custom post type – Loop out in random order but same 15 to appear first… still random
- WordPress infinite post cycle
- WordPress infinite post cycle problem
- Problem with wp_insert_post()
- How to get all posts in gallery post format template
- How to control Post view count incresing in sidebar widget posts too?
- WordPress Request Post All Post ID in a Loop? [closed]
- List Authors For Current Category
- Show Posts By Custom Field
- List of authors posts minus very latest
- WordPress loop uses unmodified posts array, why?
- Querying multiple categories in the WP loop if one of the category IDs is dynamically obtained
- Post are not showing up
- Add row after three columns
- Post Format problem
- Stop images from being displayed on the front-end of the site
- How to make post button to a random post
- Modify WordPress loop after it has been run
- Skip posts, but keep posts per page
- How to get images only attached from edit post page
- show latest authors blog post