Post (Meta Box)
Meta Boxes are used to add metadata to posts. With Cuztom it is very easy to add a Meta Box to a Post Type. Take a look here for the Wordpress docs
$box = register_cuztom_meta_box( $id, $post_type, $data );
$id
(string) The ID of the Meta Box. Used for technical stuff
$post_type
(string|array) The Meta Box will be added to this Post Type(s)
$data
(array) The data of the Meta Box
Examples
Adding a Meta Box
Adding a Meta Box with one text field.
$box = register_cuztom_meta_box(
'data',
'book',
array(
'title' => __('Data', 'cuztom'),
'fields' => array(
array(
'id' => '_data_example',
'label' => 'Example',
'type' => 'text',
)
)
)
);
Meta Box with title, description, multiple Post Types
$box = register_cuztom_meta_box(
'data',
array('post', 'book'),
array(
'title' => __('Data', 'cuztom'),
'description' => __('This a description', 'cuztom'),
'fields' => array(
array(
'id' => '_data_example',
'label' => 'Example',
'type' => 'text',
)
)
)
);
Meta Box with custom context/priority
You can change the context and priority like this.
$box = register_cuztom_meta_box(
'data',
'book',
array(
'title' => __('Data', 'cuztom'),
'fields' => array(
// Fields
)
),
'side',
'high'
);
Updated over 7 years ago