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 = new Cuztom_Meta_Box( $id, $title, $post_type, $data, $context, $priority );
$id
(string) The ID of the Meta Box. Used for technical stuff
$title
(string|array) The title of the Meta Box shown in the Wordpress backend. You can pass an array, the first element is the title, the second one is the box description.
$post_type
(string|array) The Meta Box will be added to this Post Type(s)
$data
(array) The fields (data) of the Meta Box
$context
(string) Can be 'normal', 'advanced', or 'side'. Default: 'advanced'
$priority
(string) Can be 'high', 'core', 'default' or 'low'. Default: 'default'
Examples
Adding a Meta Box
Adding a Meta Box with one text field.
$box = new Cuztom_Meta_Box(
'data',
__('Data', 'cuztom'),
'book',
array(
array(
'id' => '_data_example',
'label' => 'Example',
'type' => 'text',
)
)
);
Meta Box with title, description, multiple Post Types
$box = new Cuztom_Meta_Box(
'data',
array(
__('Data', 'cuztom'),
__('This is the box description', 'cuztom')
),
array('
'page',
'book'
),
array(
array(
'id' => '_data_example',
'label' => 'Example',
'type' => 'text',
)
)
);
Updated over 8 years ago