Uploading Multiple Attachments From Front-End With A Description

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);
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)