WordPress does not show the custom fields box?

I have created a new CPT in my wordpress locally at the moment, I need it to have custom fields and I have added it so that it does.

the code:

Read More
 register_post_type( 'centro_de_recursos',
        array(
            'labels' => array(
                'name' => __( 'Recursos' ),
                'singular_name' => __( 'Recurso' )
            ),
            'supports' => array('title', 'thumbnail', 'custom-fields'),
            'public' => true,
            'has_archive' => false,
            'rewrite' => array('slug' => 'centro_de_recursos'),
            'show_in_rest' => true, 
        )
    );

The thing is that searching for goole what I can see is that I should see in the “screen options” something like “custom fields”… And it is not like that, it has come to seem to me at certain times, but now I do not see any similar option in that field.

Why is that?

Edit: Here I show the current CPT options that appear with the supports. – enter image description here

Related posts

Leave a Reply

1 comment

  1. It’s very likely that your CPT does indeed have custom fields, but because you’re using the classic editor, you need to have also enabled custom fields on the user you’re logged in as via the user profile/settings page

    This is how core decides if there’s a custom fields metabox:

        if ( post_type_supports( $post_type, 'custom-fields' ) ) {
            add_meta_box(
                'postcustom',
                __( 'Custom Fields' ),
                'post_custom_meta_box',
                null,
                'normal',
                'core',
                array(
                    '__back_compat_meta_box'             => ! (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
                    '__block_editor_compatible_meta_box' => true,
                )
            );
        }
    

    Notice this specifically:

    '__back_compat_meta_box'             => ! (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
    

    Important

    You don’t need the custom fields metabox to use post meta. Lots of fields plugin frameworks exist, and post meta works even if the metabox isn’t present and your CPT doesn’t support them. Nothing is stopping you from using get_post_meta and update_post_meta, or registering your own custom metaboxes that read/save/update these values.

    You might see very old tutorials or tutorials from people with less experience using this as a beginner method of adding data without introducing metaboxes or sidebar panels, but modern WP development rarely relies on these.