-
Notifications
You must be signed in to change notification settings - Fork 0
Setting up Simple Meta Boxes
nadavrt edited this page Oct 3, 2015
·
3 revisions
Follow these simple steps to set up your copy of Simple Meta Boxes:
- Download and add the simple-meta-boxes folder to your project.
- include or require simple-meta-boxes.php in your theme's functions.php file.
- Create a new array to hold all your metaboxes. In the documentation we will be referring to this array as $metaboxes.
- Instantiate the Simple_Meta_Boxes class with the $metaboxes array as a parameter of the class.
Below is an example in which we include the class files, instantiate the class and pass it an array which will create a new custom meta box called Movie Information with two meta fields.
//This code should live in your functions.php file or a file included/required by your functions.php file.
include 'simple-meta-boxes/simple-meta-boxes.php';
$metaboxes = array();
$metaboxes['movie_information'] = array(
'id' => 'movie_information',
'title' => 'Movie Information',
'post_type' => array( 'movies' ),
'description' => 'You can add the movie\'s information here.',
'fields' => array(
array(
'title' => 'Production Studio',
'id' => 'production_studio',
'type' => 'text',
),
array(
'title' => 'Genres',
'id' => 'movie_genres',
'description' => 'Select the movie genres.',
'type' => 'checkbox',
'choices' => array(
'action' => 'Action',
'comedy' => 'Comedy',
'drama' => 'Drama',
'documentary' => 'Documentary'
),
),
)
);
$smb = new Simple_Meta_Boxes($metaboxes);
All set up and ready for some meta box magic? See Adding meta boxes and Adding meta fields to a meta box.