hooks - How to hideremove attachment "alt" or "caption" field in Admin?

admin2025-01-07  6

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?

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?

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Feb 8, 2017 at 20:28 AmintaCodeAmintaCode 1771 gold badge4 silver badges16 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736253192a105.html

最新回复(0)