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?
- How To Retrieve An Image Attachment’s Alt Text?
- Is wp_read_audio_metadata() function deprecated?
- Creating a metabox to upload multiple images, Ignoring The Featured Image
- Ignore a filter on the media library
- How to validate the file name of the Media File Uploads?
- Restricting access to files within a specific folder [duplicate]
- How to upload imagick resource to media in wordpress
- Upload media file problem
- Change WordPress’ media upload URL?
- Check if image exists before uploading with media_sideload_image()
- File upload, uploads only file name
- Confused with attachment mimetype order
- query attachment images … if no attachments -> get attachments of parent page?
- Replacing with(out) regex link to attachment by links to files
- Rename attachments during upload no matter what filetype
- Link all WordPress images size
- Insert attachment ID in custom field from media uploader
- Displaying Post Attachment(s) at Top of single.php
- WordPress 3.5 Media Uploader – Only allow 1 upload and certain file types
- Image Gallery Numbers for 3.5
- How can I create more upload paths, like a post corresponding to a post title folder used to store images of the same product
- How to delete a custom file from upload directory when deleting its post
- Copying media from multisite subsites to main website
- Query to only return the 2 newest post attachments (images)?
- Removal of Media Gallery pictures
- What is the best way to store thumbnails for a non-image attachment?
- Upload video in custom folder
- Weird string offset errors when displaying post attachments
- Links to my uploads went crazy
- Is there a way in WordPress to convert images to WebP without a plugin?
- Image upload to media library fails. Folder won’t create, database insert fail, XAMPP Windows
- Location of image metadata on my server
- Can’t sort get_posts by post_mime_type
- How to move an image in a plugin to the upload directory and make it as a media of wordpress?
- Whats wrong with my wp gallery?
- WordPress append -1 to the image name
- How is it possible that a gallery doesn’t have attachment ids?
- Front-End Upload media with category
- Set default “Link CSS Class” in add media admin editor
- Add link to attachment for old posts
- Is it possible to restrict the number of media uploads (photos) per user?
- How To Convert External Image URLs To Own Website’s Uploaded Images Automatically?