web-dev-qa-db-ja.com

Attachment_fields_to_edit()フィルタで追加されたフィールドの前にヘッダを追加します

添付ファイル表示フィールドの前のヘッダーのように、attachment_fields_to_edit()フィルターを使用して追加されたフィールドの前にヘッダーを追加することが可能かどうか疑問に思います。

何か案は?

ありがとう

enter image description here

PHP:

function my_attachment_fields_to_edit( $form_fields, $post ) {
    $form_fields['attachment-url'] = array(
        'label' => __( 'URL', 'plugin' ),
        'input' => 'text',
        'value' => get_post_meta( $post->ID, '_attachment_url', true )
    );
    $form_fields['attachment-width'] = array(
        'label' => __( 'Width', 'plugin' ),
        'input' => 'text',
        'value' => get_post_meta( $post->ID, '_attachment_width', true )
    );
    $form_fields['attachment-height'] = array(
        'label' => __( 'Height', 'plugin' ),
        'input' => 'text',
        'value' => get_post_meta( $post->ID, '_attachment_height', true )
    );
    return $form_fields;
}
2
leemon

行全体を作成するためにtr属性を使用できることがわかりました。

function my_attachment_fields_to_edit( $form_fields, $post ) {
    $form_fields['attachment-header']['tr'] = '
        <tr>
            <td colspan="2">
                <h2>My title</h2>
            </td>
        </tr>';
    $form_fields['attachment-url'] = array(
        'label' => __( 'URL', 'plugin' ),
        'input' => 'text',
        'value' => get_post_meta( $post->ID, '_attachment_url', true )
    );
    $form_fields['attachment-width'] = array(
        'label' => __( 'Width', 'plugin' ),
        'input' => 'text',
        'value' => get_post_meta( $post->ID, '_attachment_width', true )
    );
    $form_fields['attachment-height'] = array(
        'label' => __( 'Height', 'plugin' ),
        'input' => 'text',
        'value' => get_post_meta( $post->ID, '_attachment_height', true )
    );
    return $form_fields;
}
1
leemon