add meta box – custom field : which to choose?

A meta box is an element in the graphical user interface, a custom field is an extra key and value stored with a post. Most of the time the interface to change the value of a custom field is put in an extra meta box – or in the default meta box for custom fields, which you can enable per post type.

Maybe a picture can help explain this. I have a post with two custom fields: my_custom_field and _thumbnail_id. In the database they are stored in the wp_postmeta table:

Database rows showing custom field data

But in the post interface they can be edited in different places. The _thumbnail_id is displayed in the Featured Image meta box and can be edited with the image browser because it is hard to know the attachment ID. The other value can just be edited via the “generic” Custom Fields meta box:

Custom Fields and Featured Image meta boxes

It will depend on the values you need to enter in your plugin and the experience of your users whether the Custom Fields meta box is enough, otherwise it will be more user-friendly to add a separate meta box.

Leave a Comment