如何在posttype / postmeta中添加metabox.io?

时间:2016-01-21 02:56:53

标签: wordpress meta-boxes

我尝试将metabox.io集成到我自己的自定义postmeta插件中,

我试图将添加过滤器代码移动到我的插件文件

add_filter( 'rwmb_meta_boxes', 'your_prefix_meta_boxes' );
function your_prefix_meta_boxes( $meta_boxes ) {
    $meta_boxes[] = array(
        'title'      => __( 'Test Meta Box', 'textdomain' ),
        'post_types' => 'post',
        'fields'     => array(
            array(
                'id'   => 'name',
                'name' => __( 'Name', 'textdomain' ),
                'type' => 'text',
            ),
            array(
                'id'      => 'gender',
                'name'    => __( 'Gender', 'textdomain' ),
                'type'    => 'radio',
                'options' => array(
                    'm' => __( 'Male', 'textdomain' ),
                    'f' => __( 'Female', 'textdomain' ),
                ),
            ),
            array(
                'id'   => 'email',
                'name' => __( 'Email', 'textdomain' ),
                'type' => 'email',
            ),
            array(
                'id'   => 'bio',
                'name' => __( 'Biography', 'textdomain' ),
                'type' => 'textarea',
            ),
        ),
    );
    return $meta_boxes;
}

但元数据只在主帖中显示而不是在我的postmeta中?

如何在我的自定义postmeta中添加metabox.io?

2 个答案:

答案 0 :(得分:0)

假设我正确地阅读了你的问题,你试图将它添加到你的插件使用的元数据库中。

考虑到这一点,你可以搞乱过滤器和代码放置数据的位置,但你可能最好从github分配项目并根据你的需要重写它的界面。这当然是假设许可证允许的。

在个人使用之前,你应该能够通过编写管理钩子和过滤器来自定义它在仪表板上的外观和功能。

如果我对你的要求不对,请告诉我,我会再试一次。

答案 1 :(得分:0)

哦对不起,我终于找到了答案

要与posttype集成,我只需要更改第5行中的post_types

'post_types' => 'post',

用我自己的帖子类型。