[WP] 自定义 metabox

更新 2020年5月1日 发布 2019年7月21日  WP & Websites
// metaboxes
function reference_meta_box( $meta_boxes ) {
    $prefix = 'reference-';

    $meta_boxes[] = array(
        'id' => 'reference',
        'title' => esc_html__( '转载/参考', 'metabox-online-generator' ),
        'post_types' => array( 'post', 'article' ),
        'context' => 'normal',
        'priority' => 'default',
        'autosave' => 'true',
        'fields' => array(
            array(
                'id' => $prefix . 'all',
                'type' => 'fieldset_text',
                'name' => esc_html__( '转载', 'metabox-online-generator' ),
                'rows' => 1,
                'options' => array(
                    'title' => '标题',
                    'author' => '作者',
                    'source' => '地址',
                ),
                'attributes' => array(
                    'size' => '60',
                ),
                'clone' => 'true',
            ),
            array(
                'id' => $prefix . 'part',
                'type' => 'fieldset_text',
                'name' => esc_html__( '参考', 'metabox-online-generator' ),
                'rows' => 1,
                'options' => array(
                    'title' => '标题',
                    'author' => '作者',
                    'source' => '地址',
                ),
                'clone' => 'true',
                'attributes' => array(
                    'size' => '60',
                ),
            ),
        ),
    );

    return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'reference_meta_box' );