Gutenberg: Custom fields in custom post type not appearing

Created on 27 Jun 2019  路  4Comments  路  Source: WordPress/gutenberg

hi,
i was looking for a similar issue, but i found nothing. if there was already i apologize in advance.

Describe the bug
after creating a custom post type, i am not able to see the custom fields.

To reproduce

  1. fresh install
    2.
function register_custom_post_types() {
    register_post_type('test', [
        'labels' => [
            'name' => __('test'),
        ],
        'public' => true,
        'supports' => [
            'title',
            'editor',
        ],
        'show_in_rest' => true,
    ]);
}
add_action('init', 'register_custom_post_types');
  1. create a new cpt post and try to activate the custom fields in the options modal
  2. (forced) refresh
  3. nothing appears and the custom fields checkbox still unchecked

Expected behavior
the custom fields appear a the bottom of the editing page of the custom post type.

Screenshots
image

Desktop:

  • OS: windows
  • Browser firefox
  • Version 67.0.4 and 68.0b13

Additional context
wordpress 5.2.2

[Feature] Meta Boxes [Type] Bug

Most helpful comment

Yes, it's a bug. The option should be not visible when the post type doesn't support this feature. I opened a PR #16338 with a solution. When it's merged we close this issue..

All 4 comments

You need to add custom-fields to the supports array, see docs https://developer.wordpress.org/reference/functions/register_post_type

We should only show this option, if the post type supports this feature.

sorry for reporting a non bug. i did not notice about that in the documentation.
thank you for the answer.
is it anyway considered as bug because the custom fields checkbox should not appear at all, or i can close this issue?

Yes, it's a bug. The option should be not visible when the post type doesn't support this feature. I opened a PR #16338 with a solution. When it's merged we close this issue..

Was this page helpful?
0 / 5 - 0 ratings