Until WP 3.6 it was possible to remove the "alt" field (and also the "caption" field) before showing a post of type "attachment" through attachment_fields_to_edit hook.

As you can see also here (user Olemak's comment to the solution) WP removed the possibility to...remove fields from that hook from 3.6 version on.

Do you know other methods to get this result in WP, or I have to resort to a Css-only solution?

1 Answer 1


The attachment_fields_to_editfunction returns an array variable called: $form_fields, which contains all the data. So as it is an array, we could make any of these operations in this link.

There are some methods to delete an array element, including unset() method, which I think it's the easy method to use.

And to delete the caption field, I'm not so sure but I think you should unset this: $form_fields['post_excerpt'], this contains the caption content. Take a look at the code function in this code link.

  • no, $form_fields is given as an empty array in "attachment_fields_to_edit" hook, as from WP 3.6 onwards....
    – AmintaCode
    Commented Feb 8, 2017 at 23:19
  • Hey! You're right, I haven't noticed! Seems to work only to add new fields, sorry. Maybe using JS or CSS, could be the best option. Commented Feb 9, 2017 at 0:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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