0

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.