/** Add new Custom Field On Media detail page */ function add_custom_media_fields($form_fields, $post) { $form_fields["externalUrl"] = array( "label" => __("External URL"), "input" => "text", // this is default if "input" is omitted "value" => get_post_meta($post->ID, "externalUrl", true) ); return $form_fields; } add_filter("attachment_fields_to_edit", "add_custom_media_fields", null, 2); /** Save the new custom field value into database*/ function save_custom_media_fields($post, $attachment) { $my_data = sanitize_text_field( $attachment['externalUrl'] ); update_post_meta( $post['ID'], 'externalUrl', $my_data ); return $post; } add_filter('attachment_fields_to_save', 'save_custom_media_fields', 10, 2);Hope you will all enjoy my code.
How to Add New Custom Filed ON Media Image Pages : WordPress
Hello Friends!!
Hope you all are doing well :)
In admin if you want to add new custom field on media details page then you can do it in a easy way. You will not need to edit in wordpress core files , using wordpress hooks you can do it by add the code in your theme function file.
I am given to a example for add to new field "External URL", You will need to add the code in your theme function file.