I’m trying to remove the caption field from non-images attachments’ edit page, which should be a simple matter of unset($post['post_excerpt'])
, but I can’t unset a non-existent value…
Looking at the core, this Array being empty should mean that no fields exist on the attachment page, but all the expected fields are there (plus custom ones I’ve added). I’m completely and utterly baffled.
I’ve tried extremely high & extremely low priority values in applying the filter, neither of which makes a difference.
Below is a test case showing the empty Array before and the Array with just my custom field after.
function attachment_fields_edit( $form_fields, $post ) {
print_r( $form_fields ); // Array ( )
$form_fields['author'] = array(
'label' => __('Author'),
'input' => 'text',
'value' => get_post_meta( $post->ID, "author", true ) );
print_r( $form_fields );
/* OUTPUT:
Array
(
[author] => Array
(
[label] => Author
[input] => text
[value] => Author Name
)
)
*/
}
add_filter( 'attachment_fields_to_edit', 'attachment_fields_edit', null, 2 );`
I don’t know what to do about this. It makes no sense based on the code I’m looking at. Any help would be appreciated!
PS: Given recent changes to the Media Manager, my working theory is that this may be related in some way to this change…