我想在我的每张图片下显示来源。所以基本上我想添加一个简单的自定义字段。我将此代码添加到我的函数中。php
add_filter(\'attachment_fields_to_edit\', \'edit_media_custom_field\', 11, 2 );
add_filter(\'attachment_fields_to_save\', \'save_media_custom_field\', 11, 2 );
function edit_media_custom_field( $form_fields, $post ) {
$form_fields[\'custom_field\'] = array( \'label\' => \'Custom Field\', \'input\' => \'text\', \'value\' => get_post_meta( $post->ID, \'_custom_field\', true ) );
return $form_fields;
}
function save_media_custom_field( $post, $attachment ) {
update_post_meta( $post[\'ID\'], \'_custom_field\', $attachment[\'custom_field\'] );
return $post;
}
到目前为止还可以。但后来事情变得一团糟。现在我的问题是在哪里可以添加第二个调用代码,我的意思是。php
get_post_meta( get_the_ID(), \'_custom_field\', true ) );