Is it possible to remove a default attachment field from the attachment editor, for example the “Caption” field ?
To give you some context, I’m trying to build a custom attachment editor page. I found how to add custom fields, now I’d like to remove some of the default ones I don’t need.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Use the attachment_fields_to_edit filter to remove the fields you don’t want displaying from the array.
function remove_caption($fields) {
unset($fields['post_excerpt']); // See wp-adminincludesmedia.php line 1071
return $fields;
}
add_filter('attachment_fields_to_edit','remove_caption');
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0