Don’t you need to use get_posts( 'post_type=attachment' )
to return the attachment IDs? So, something like:
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts( $args );
$myimageid = $attachments[0]->ID;
wp_get_attachment_image( $myimageid, 'full' );
Otherwise, you’re using $post->ID of 1, which isn’t likely to work.
Related Posts:
- Programmatically adding images to the media library with wp_generate_attachment_metadata randomly fails
- How can I bulk delete media and attachments using WP-CLI?
- complex restriction of items in media library
- Edit image / Delete image link
- media_sideload_image file name?
- Get all posts (of any post type) an attachment is used in
- Unattaching unlinked images
- Show Post ID in “Find Posts or Pages” box in Media Library?
- Gel all image from certain post type
- Can i hide the attachments from media which I uploaded from front end?
- Get the attachment URL on single.php
- Perform a custom (bulk) action in media view
- How to retrieve alt attribute for an attachment (uploaded image)?
- Where does the gallery shortcode gets its attachments from?
- Control attachments menu order with jQuery Sortable
- Is it possible to share media files between multiple WordPress sites?
- Open the Attachment Details popup
- how to get random media id from media gallery
- Upload multiple image with media_handle_upload with multiple file field [duplicate]
- Get an image from the media library. Struggling with the code?
- Media Library Mess After FTP … /uploads
- Media item permalink goes to source file instead of attachment.php
- wp_get_attachment_image_src calling wrong location
- Removing images deleted from uploads folder, from Media Library
- WP media attachment location vs permalink
- Removing delete permanently button in uploading files media
- Retrieve ONLY mp3s and set a variable for use in a playlist called by single.php template?
- Is there a way to add Reattach and Unattach links in image gallery?
- How to retrieve images contained in a post
- How to save media-form on custom tab
- Bulk delete media by year
- Media library upload hook
- How To Retrieve An Image Attachment’s Alt Text?
- How to get attachment file name not attachment URL
- Custom collection in media manager?
- How to cleanly delete attachment but retain original file?
- Uploading Multiple Attachments From Front-End With A Description
- Validate alt text for attachments?
- Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?
- How can I display custom fields value from attachment media?
- how to test for attached image
- Unable to upload specific .zip file type via frontend in WordPress 4.0
- Add_Filter example for wp_get_attachment_link
- attachment url rewrite
- Automatically delete attachments and posts [closed]
- How to delete orphan attachments?
- Adding File Extensions to Attachment Page Permalinks
- Get the title and URL of the attachment parent post
- Confused with attachment mimetype order
- Disable edit media attachments?
- Post Auto Draft Issue
- Link all WordPress images size
- post_author for wp_insert_attachment
- Detach an image from a page using php
- Get the path of the first attached media (single.php)
- Ordering of gallery images without using shortcode in theme
- Adding width and height to wp_get_attachment_image_src
- custom admin thumbnail for videos, not getting post’s id?
- Audio file’s length (duration) is missing from Attachment Details in Media Library [closed]
- Media library quick/inline edit
- Check what attached image size is used
- How to filter a post in the Tag Cloud widget, using tags of a media library image attached to the post?
- Clean up images, delete unused image sizes attached to a post type
- Custom image sizes add to metadata
- What is the best way to store thumbnails for a non-image attachment?
- Add attachment for all images in post
- What will happen if I delete all my attachment type posts from database?
- filter get_children to return all mime types EXCEPT ‘x’
- Update media library image shown in “attachment details” when using wp_insert_attachment to add item to the media library
- Weird string offset errors when displaying post attachments
- the_time() returning wrong date/time (way in the future)
- Add audio attachment link to RSS
- Links to my uploads went crazy
- hide attached images of a post
- How to add a caption to an image attachment in a file list?
- Undoing define( ‘UPLOADS’, ”.’files’ ); to repoint to “wp-content/uploads” folder
- Upload image and assign it’s id to post
- Possible to add “Even/Odd Classes” to image attachments via wp_get_attachment_image?
- Can’t sort get_posts by post_mime_type
- How can I rewrite old attachment URLs?
- All images on one line for each post
- How to list “invisible” Auto Drafts?
- How to add media from front-end to an existing post and edit file title
- Auto delete content in specific folder inside media library
- How is it possible that a gallery doesn’t have attachment ids?
- Display audio file in audio.php
- Attachment file display link text
- Get video attachment ID and display length
- missing attachment are showing as 404
- Insert attachments from front end form
- controlling whether upload is attached to post or not
- How do I add Facebook OpenGraph meta tags for attachments in the header for a custom theme?
- Add link to attachment for old posts
- Drupal 6 to WordPress migration – media attachments
- Attachment Metadata not updated while uploading audio files
- Move caption in on attachment page
- Change attachment inside the_content using filters
- Count images in post then add class if just one
- One audio attachment, with two possible interchangeable extensions
- How can I use an image from an external source without uploading it to the media library