The audio_submitbox_misc_sections WordPress PHP filter allows you to modify the audio attachment metadata fields displayed in the publish meta box.
Usage
add_filter('audio_submitbox_misc_sections', 'my_custom_audio_fields', 10, 2); function my_custom_audio_fields($fields, $post) { // Your custom code here return $fields; }
Parameters
- $fields (array) – An array of the attachment metadata keys and labels.
- $post (WP_Post) – WP_Post object for the current attachment.
More information
See WordPress Developer Resources: audio_submitbox_misc_sections
Examples
Add a custom field to the audio metadata
This example adds a custom field “Custom Text” to the audio metadata.
add_filter('audio_submitbox_misc_sections', 'add_custom_text_field', 10, 2); function add_custom_text_field($fields, $post) { $fields['custom_text'] = 'Custom Text'; return $fields; }
Remove a specific field from the audio metadata
This example removes the “Length” field from the audio metadata.
add_filter('audio_submitbox_misc_sections', 'remove_length_field', 10, 2); function remove_length_field($fields, $post) { unset($fields['length']); return $fields; }
Change the label of a field in the audio metadata
This example changes the label of the “Artist” field to “Singer”.
add_filter('audio_submitbox_misc_sections', 'change_artist_label', 10, 2); function change_artist_label($fields, $post) { $fields['artist'] = 'Singer'; return $fields; }
Reorder fields in the audio metadata
This example reorders the audio metadata fields, placing the “Album” field before the “Artist” field.
add_filter('audio_submitbox_misc_sections', 'reorder_audio_fields', 10, 2); function reorder_audio_fields($fields, $post) { $new_fields = [ 'length' => $fields['length'], 'album' => $fields['album'], 'artist' => $fields['artist'], ]; return $new_fields; }
Add multiple custom fields to the audio metadata
This example adds two custom fields, “Composer” and “Year”, to the audio metadata.
add_filter('audio_submitbox_misc_sections', 'add_multiple_custom_fields', 10, 2); function add_multiple_custom_fields($fields, $post) { $fields['composer'] = 'Composer'; $fields['year'] = 'Year'; return $fields; }