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:
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. –
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:
Notice this specifically:
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
andupdate_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.