How to add custom fields to attachments?
Just a question:
How do we add custom fields to attachments with Carbon Fields?
Been wondering the same question
https://docs.carbonfields.net/learn/fields/file.html#config-methods
Is this document helpful?
Hi @lautiamkok ,
In order to create custom fields for the attachment post type you only have to specify the "post_type" where clause in the post_meta container.
Here is an example of usage:
Container::make( 'post_meta', __( 'Attachment Settings', 'crb' ) )
->where( 'post_type', '=', 'attachment' )
->add_fields( array(
Field::make( 'text', 'crb_attachment_content', __( 'Additional Content', 'crb' ) )
) );
Then you could enter the "Edit Post" page of every attachment and use the fields. When you open an attachment popup click on the "Edit more details" link to get to the "Edit Post" page. Here is an example image: https://i.imgur.com/QEHimUD.png