• 介绍标签:form,fields,value,field,添加,WordPress,attachment,附件,post From: https://blog.51cto.com/suren/5764019
WordPress的附件(多媒体)默认已经有一些对应的属性了,我们还可以再添加一些信息。
• 玉照
[caption id="attachment_3523" align="aligncenter" width="399"] wp_attachment_field[/caption]
• 代码
[codesyntax lang="php"]
add_filter('attachment_fields_to_edit', 'suren_attachment_fields_to_edit', 10, 2);
function suren_attachment_fields_to_edit($form_fields, $post)
{
$field_value = get_post_meta($post->ID, 'license', true);
$form_fields['license'] = array(
'value' => $field_value ? $field_value : '',
'label' => __('License'),
'helps' => __('Specify the license type used for the image')
);
return $form_fields;
}
[/codesyntax]