How to update the title of audio file through its attachment metadata

by user3821501   Last Updated January 26, 2019 12:08 PM

I am trying to programmatically update some metadata of audio file attached to a post. I have been able to update the artist and album properties of the audio file but title doesn't stick. I can go through media library and edit the title and it works but not through backend. Can you please assist? Here's how I do so now:

              $meta = wp_get_attachment_metadata( $attachment->ID, false);

              $meta = array (
             'artist' => $mainArtist,
                     'title' => $TitleAndFeaturedArtist,
             'album' => ' ',
                            );

                    wp_update_attachment_metadata( $attachment->ID, $meta);

The artist and album gets updated but not title. Title seems to be coming from the iD3 tag but through media library in wordpress, you can edit and set yours. I am trying to avoid manually processing over 2000 files. There has to be a way :(

Please help. Any suggestions or alternative would help



Answers 1


I figured this out. It's because the title isn't part of the attachment metadata technically. The audio attachment itself is stored in the database as a post with a post type of attachement and applicable mime type. To update the title of the audio is to update the post title

user3821501
user3821501
November 25, 2014 17:48 PM

Related Questions


Frontend form with multiple posts

Updated July 02, 2018 14:08 PM

How trigger to save post when updating post meta

Updated October 14, 2017 08:08 AM

Set Attachment Image File URL as GUID

Updated October 19, 2017 13:08 PM

Display audio file in audio.php

Updated May 07, 2018 13:08 PM