Looks like you may have just not had a loop setup, try this one
<div class="two_images">
<?php
global $post;
$args = array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC',
'numberposts' => 2 );
$images = get_posts($args);
if ( $images ) {
$i = 0;
while($i <= 1){
echo wp_get_attachment_image( $images[$i]->ID, 'full' );
$i++;
}
}
?>
</div>
Related Posts:
- Can I add a Category Metabox to attachment?
- How to trigger a refresh in the media modal
- Get all post attachments except featured image
- How can I bulk delete media and attachments using WP-CLI?
- Getting a taxonomy’s thumbnail url
- Check if post has attachments (not image)
- Changing attachment urls?
- Add custom class to attachment in media library grid mode
- How can I UN-attach media from a post?
- How to get attachment caption (get_the_excerpt gives parent post excerpt) ?
- Is it possible to query specific WordPress Attachment files (.ppt & .pdf) and output them in a list?
- Unattaching unlinked images
- How to get attachments for a specific post type?
- How to add media from front-end to an existing post?
- Get attachment from post
- Get attachments (get_posts) and WP 3.5 new uploader
- Change image link: wp_get_attachment_link
- Multi-line captions on attachments
- Make individual attachments private?
- exposing attachment uploading to the front end — delicate
- Gel all image from certain post type
- Change the Permalink for wordpress attachment
- Get the attachment URL on single.php
- How to get list of paths (not urls) for an image
- Adding attachment file name to email link
- attachments with tags and get_posts
- Hide “Gallery Settings” and “Insert into Post” button from Attachment window
- How can I change wordpress attachment url and protect it?
- Adding class to next/prev image link in attachment.php
- How to add multiple checkbox elements to media attachments?
- Get attachment next and previous by author only
- Edit default image attachment size
- Perform a custom (bulk) action in media view
- How to make a customized “Create Gallery” tab in the ‘Add Media’ window?
- Strip the folder path away from wp_get_attachment_url to show filename only
- How to retrieve alt attribute for an attachment (uploaded image)?
- Need to get array of images ID attached to post
- Show attached media image if no thumbnail image detected
- How to set a conditional statement for $attachment->post_excerpt, to check for value?
- wp_mail not sending attachment
- How to check if there is image title, caption, description?
- Display random gallery images and its parent post title leading to parent post permalink
- Don’t show attachments if they are inserted in post
- How to remove attachments size attribute [duplicate]
- Email Attachment from Form Submit
- hook wp_generate_attachment_metadata does not read all the attachments
- How do I get all attachments that are used in the current post, not just the children?
- Massive photogallery import
- Is there a move_attachment_file() function in wordpress?
- How do you create an attachment ID with Ajax submit? No page refresh
- Auto create file and send it via wp_mail()
- Create page from post attachments
- how to get random media id from media gallery
- Attach pdf from dynamic url
- Post Gallery list attachments except the one used as post thumbnail
- Echo Permalink in Attachment outside of loop?
- How can I display a link to a post’s (Word doc or pdf) attachment?
- GUID field in wp_posts – relevance for attachments?
- Is there a function for getting the post/page that an attachment is related to?
- Prevent image from being accessible via url as a post?
- Upload multiple image with media_handle_upload with multiple file field [duplicate]
- get_post orderby not working in plugin
- Delete child post and attachment links to parent post
- Remove attachment from database
- Get Attachment Image Class by attachment id
- Automatically deactivate link for attachments
- Display Audio Attachment URL
- How to set order for attachment form field?
- Display a post attachment depending on the caption
- changing the default picture size link url
- File Attachment display title in template
- add image caption
- Get an image from the media library. Struggling with the code?
- Get all post embedded images
- Programmatically Altering Gallery Link and image size?
- Filter not applied to all image sizes
- Zip a file and add as attachment
- Remove post with attachments hook
- Setting an image as post header (not featured image)
- File was uploaded, but it is not shown on media section of the dashboard
- Using the GetMediaLibrary() method in python-wordpress-xmlrpc.media, how to iterate over the result?
- wp_get_attachment_metadata is empty
- Restricted Attachments/Change Attachment Upload Location
- Hide Image Container if No Image Attachments
- How to link images to attachment.php [duplicate]
- Check whether attachment ID is associated with more than one post?
- How to remove attachments from main query via pre_get_posts?
- Post attachments doesn’t show after manual db import
- Is there a way to add Reattach and Unattach links in image gallery?
- Possible to “Attach” images to multiple posts without uploading twice from Add media Section?
- How to get boolean if file A is attached to post B
- ID of images from gallery
- WordPress Attachments vs Post Meta
- open image after clicking on single.php with different stylesheet in wordpress
- WPML : how to pick a featured image only once for different languages?
- How do I get link URL (not file URL or attachment URL) of an attached image [duplicate]
- Attachment page custom title?
- Custom Fields, Media uploader, Attachments
- One audio attachment, with two possible interchangeable extensions
- Attachement Meta DATA