custom field - Add metabox to document tab in gutenberg

How can I add custom metabox in document tab in gutenberg?There is documentation about adding plugin sidebar here, but I

How can I add custom metabox in document tab in gutenberg?

There is documentation about adding plugin sidebar here, but I'm looking for adding custom metabox in existing document tab.

How can I add custom metabox in document tab in gutenberg?

There is documentation about adding plugin sidebar here, but I'm looking for adding custom metabox in existing document tab.

Share Improve this question asked Feb 3, 2019 at 15:38 AnkitAnkit 3543 silver badges10 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 8

Here is the solution. Hope it will help you

const { registerPlugin } = wp.plugins;
const { PluginDocumentSettingPanel } = wp.editPost;

const MyDocumentSettingTest = () => (
        <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel">
            <p>My Document Setting Panel</p>
        </PluginDocumentSettingPanel>
    );

registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );

https://github/WordPress/gutenberg/blob/master/packages/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js#L86

I took a look at Richard Tape's article which required you create your own Gutenberg React component (which is likely the best, most customisable way to do it). But I also have Advanced Custom Fields Pro installed (it has to be version 5.8.0-beta3). That provides a much easier method to add a custom meta field to the Gutenberg sidebar.

Create a new field in ACF Pro and in the Field group settings, ensure you have the following settings configured:

  1. Style: Standard (WP Metabox)
  2. Position: Side

This has worked for me ( added a Reading time field). Hope this helps.

https://wordpress/gutenberg/handbook/designers-developers/developers/backward-compatibility/meta-box/ and https://developer.wordpress/reference/functions/add_meta_box/

use $context = 'side'

Example:

add_meta_box( 'my-meta-box', 'My Meta Box', 'my_meta_box_callback',
    null, 'side', 'high',
    array(
        '__back_compat_meta_box' => true,
    )
);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744635185a4585103.html

相关推荐

  • custom field - Add metabox to document tab in gutenberg

    How can I add custom metabox in document tab in gutenberg?There is documentation about adding plugin sidebar here, but I

    2天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>