This should do it, I think:
function get_images() {
global $post;
$attachment = get_children(array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'numberposts' => -1 ),
ARRAY_N );
if ( $attachment ) {
$attachment_count = count($attachment);
foreach($i=0; $i < $attachment_count; $i++) {
$last = ($i == ($attachment_count-1) ) ? ' last' : '';
echo '<img src="' . wp_get_attachment_url($attachment[$i]->ID) .
'" class="post-attachment'.$last.'" />';
}
}
}
Related Posts:
- How do I change/modify the_post_thumbnail(); html output?
- What’s the best way to use the Featured Image for responsive web design?
- PHP/Manual use of images? – 2 Questions
- Adding Featured Image to Post programatically
- How to upload imagick resource to media in wordpress
- How to add a featured image to a existing post via php?
- How to use SRCSET with get_the_post_thumbnail()?
- Adding featured image via PHP
- WordPress loop specific thumbnail size
- How do I get images (with a thumbnail preview) to show in search results?
- fallback image for featured image
- How to get Poster (thumbnail) Image of Video
- WP Insert Post function – Insert Post Thumbnail
- How to make thumbnail image fit into a div where image dimentions are completely different?
- Assign a picture URL to a page via PHP
- How to scale image with equal width and height without distortion?
- Featured image fallback link to permalink
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- How to Display Image Meta underneath EVERY image in EVERY post
- How can I show the post thumbnail from the most recent of a certain post type, in widget?
- How can I add pagination and how can I change thumbnail size?
- Echo URL of large version of Featured Image
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Trying to add attribute to my posts’ featured image
- Recent posts with featured image or fallback image with permalink
- Randomly Assign an Image’s Alt Text Based on Data From Post
- WP dynamic featured image – Can’t get second featured image url
- Set the background to a default image if there isn’t a specified “featured image”
- PHP variable = get_the_post_thumbnail_url outputting without slashes
- Is it possible to use Data URI image to set a post thumbnail?
- WP Post-Thumbnail
- Display custom post type title as text if post thumbnail is not available
- post thumbnail, conditions, else wont work
- ‘Post-thumbnails’ feature does not seem to register
- height should be set to auto to avoid pixelation in the post thumbnail function
- Three Questions with Twenty Eleven theme
- Display related posts without a plugin
- WordPress function and string as variable?
- Resize image to specific dimension (X to Y ratio)
- Apply class to every third list item? [duplicate]
- Automatically add images to a menu
- Using featured image of blog archive page
- if custom field doesn’t exist, use post thumbnail instead, as image background
- Help Fallback (thumbnail)
- Get featured image with custom size outside WordPress
- How to add post thumbnail dynamically using Jquery?
- Else/If Statement to Display Photo Descriptions
- How to set a featured image (thumbnail) with PHP?
- How to change thumbnail src attribute?
- Error display post thumbnails for previous and next post
- Get the featured image url of clicked post
- Fallback image URL if no featured image exists via a shortcode function
- How to replace URL protocol using PHP?
- Call featured image url
- How to pick “full/thumbnail” images in the loop?
- Generate responsive post thumbnails of same size
- How to Make Thumbnail of Post Stay Animated
- Get the alt text of the image in a array
- Trying to change featured image from 180×180 to full width on home page
- Show different size featured images (the_post_thumbnail) for 1st, 2nd and 3rd posts?
- Need to add a post’s featured image to a section on the frontpage
- I can’t set image ad fatured programatically
- Add Featured Image to Existing Post
- wp_query – Exclude the first thumbnail from lazy loading on archives
- not outputting medium size image URL
- Replace background image with post thumbnail in shortcode
- Resize post thumbnail
- How to put 2 php codes in functions.php without site crashing
- How to add WordPress Featured image in tag ..?
- WordPress generate images size after upload
- Add a default style if no Featured image is selected
- How to link all featured images to custom url in single.php for only non-logged-in users?
- How to programmatically set existing image in media library the featured image for a post in wordpress
- Having trouble with customizing blog posts on the home page
- How to link featured images in single.php for only non-logged-in users?
- Thumbnail wouldn’t scale to size properly
- get_post_thumbnail_id returns a negative number
- Basic PHP question (displaying post title over thumbnail) [closed]
- Showing featured image of page’s child’s children page
- insert thumbnail image from php script
- Can’t put a hyperlink on Featured Post’s Image
- add class to background image
- News and Featured image
- How to correctly add the featured immage (thumbnails) support in a WP theme? Why I can’t add a featured immage?
- Overwriting a Shortcode
- featured post as div background
- How to display thumbnail if post is assigned one otherwise not
- Post Thumbnail on Single (if elseif else)
- the_post_thumbnail unless video id is added
- Setting post thumbnail sizes in template file and functions.php
- How can i give a download link to the thumbnail or featured image
- add if statement to the featured image
- How to crop featured image in different sizes?
- Remove default Image Sizes
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- Generate and upload screenshot as featured image for user-submitted post
- Fatal error: Call to undefined function wpsc_cart_item_count()
- Language does not switch while cache is enabled
- Adding unique marketing messages between certain products whilst using isotope/Infinite Scroll
- get_permalink returning first letter