I eventually worked this out. After a lot of thinking it dawned on me that attachments are merely posts assigned to the post_type of ‘attachment’ so then I soon discovered that attachments have a post_content field, as well as a post_title field. For my needs, I only needed the post_title attribute as my descriptions are small. The below code is what worked for me.
The $upload_id value is merely the attachment ID returned from my insert_attachment function.
// Make sure we have an attachment ID
if ($upload_id != 0)
{
// Insert the upload description a.k.a post title
$post_data = array();
$post_data['ID'] = $upload_id;
$post_data['post_title'] = $file_title;
wp_update_post($post_data);
}
Related Posts:
- How to retrieve alt attribute for an attachment (uploaded image)?
- wp_delete_attachment doesn’t delete image files / doesn’t work
- How to Fix HTTP Error When Uploading Images?
- How to manage attachment relationships for specific posts in WP 3.5+
- How to trigger a refresh in the media modal
- How can I bulk delete media and attachments using WP-CLI?
- Can I use the wp media uploader for my own plugin?
- Expanding new Media Uploader in WordPress 3.5
- media_sideload_image file name?
- Get all posts (of any post type) an attachment is used in
- How to get all files inserted (but not attached) to a post
- Password protect some uploaded files, so only logged-in users can view them
- How to single click to download image in single post
- Unattaching unlinked images
- How to add media from front-end to an existing post?
- Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?
- Delete attachments from Front end
- Creating a multi-file upload form on the front end for attachments
- How do i upload an image and return the image id?
- Get attachments (get_posts) and WP 3.5 new uploader
- exposing attachment uploading to the front end — delicate
- How to upload image from front end and save in media library?
- Upload images and attachments from frontend form
- How to delete orphan attachments?
- How to count media attachments?
- Getting ID from ajax response of async-upload.php
- How to make a customized “Create Gallery” tab in the ‘Add Media’ window?
- rename attachments based on parent-post-title on upload
- Get the path of the first attached media (single.php)
- Show attached media image if no thumbnail image detected
- Images not being generated at correct size
- Use the WP media uploader dialog for uploading a form attachment (non-admin). Offering progress and drag and drop feedback
- media ‘path’ issue / concern when bringing files live
- Handling image uploads without thickbox
- Media library quick/inline edit
- Email Attachment from Form Submit
- How to compress image before inserting to wordpress using wp_insert_attachment function?
- Massive photogallery import
- What is the way to add additional fields to attachments in 3.5+?
- Get images attached to a specific page
- the_time() returning wrong date/time (way in the future)
- How does WordPress decides how many sizes of an image to create?
- Gutenberg Block: Image resolution
- Upload multiple image with media_handle_upload with multiple file field [duplicate]
- Undoing define( ‘UPLOADS’, ”.’files’ ); to repoint to “wp-content/uploads” folder
- Insert attachments from custom uploader into post (regular uploader style)
- Do custom post type (CPT) attachments/media store the parent post ID?
- Media Library Mess After FTP … /uploads
- Adding attachment custom field metadata to TinyMCE tag
- 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?
- Check if author or uploader id of the attachment(uploaded) image is match?
- Using $_FILES variable into the same function for uploading images and files
- Limit attachment caption characters
- controlling whether upload is attached to post or not
- Remove attached media
- How to properly move media files and update data?
- Get Specific Files (Only Specific Extension Type All Files in Loop ) from Media
- How can I get all attachments by a user on a WP multisite network?
- How to Protect Uploads, if User is not Logged In?
- How To Retrieve An Image Attachment’s Alt Text?
- How to add new tab to media upload manager with custom set of images?
- Add “upload media” button in meta box field
- Can I add a Category Metabox to attachment?
- Extend Media Library
- How Can I Add the “Insert From URL” Tab to a Custom 3.5 Media Uploader?
- How does WP media uploader create the 3 different sized images, and how can I duplicate it
- How to make “Upload files”selected by default in Insert Media?
- WordPress 3.5: Setting custom “full URL path to files” in the Media Library?
- “Add Media” button in custom plugin
- Change attachment filename
- How to get attachment file name not attachment URL
- Submit post and upload image from front-end
- Upload images to remote server
- simple solution for restricting access to (some) uploads/downloads
- what happens to existing media files when I switch to year/month directory structure format?
- Reject upload of wrong-sized images using the Media Uploader
- How to use taxonomies on attachments with the new Media Library?
- Get upload URL by blog ID in multisite
- How to show all available images in WP’s media library when using the Polylang plugin?
- How to increase the file size limit for media uploads?
- How to add a custom field to the media screen (image/gallery)?
- Uploading media with the REST API
- Saving data-URI to media library
- Can’t upload media, permissions are correct
- Get all post attachments except featured image
- Programmatically adding images to the media library with wp_generate_attachment_metadata randomly fails
- getting attachement images src and add classes
- Saving Media – Which Hook is Fired?
- Set limit to media upload?
- How to restrict access to uploaded files?
- WordPress 3.5: Switch back to Old Media Uploader?
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- upload_async.php returns 500 error
- Which filters or actions to use after a media upload and delete?
- Decrease file size upload in Media
- Remote upload file to server B
- Display attachments by ID in a wp.media frame
- Use a separate custom table (not posts) to handle file upload data