04/30/2018 at 3:17 pm
#460850
Keymaster
@ Seun Tayo
Yes, that is correct. The full code would be like this to add three fields:
// Register the metabox and fields.
add_action( 'cn_metabox', 'cn_register_custom_metabox_and_text_field' );
function cn_register_custom_metabox_and_text_field() {
$atts = array(
'title' => 'Metabox Name', // Change this to a name which applies to your project.
'id' => 'custom_one', // Change this so it is unique to you project.
'context' => 'normal',
'priority' => 'core',
'fields' => array(
array(
'name' => 'Field Name', // Change this field name to something which applies to you project.
'show_label' => TRUE, // Whether or not to display the 'name'. Changing it to false will suppress the name.
'id' => 'field_id', // Change this so it is unique to you project. Each field id MUST be unique.
'type' => 'text', // This is the field type being added.
'size' => 'regular', // This can be changed to one of the following: 'small', 'regular', 'large'
),
array(
'name' => 'Field Name', // Change this field name to something which applies to you project.
'show_label' => TRUE, // Whether or not to display the 'name'. Changing it to false will suppress the name.
'id' => 'field_id', // Change this so it is unique to you project. Each field id MUST be unique.
'type' => 'text', // This is the field type being added.
'size' => 'regular', // This can be changed to one of the following: 'small', 'regular', 'large'
),
array(
'name' => 'Field Name', // Change this field name to something which applies to you project.
'show_label' => TRUE, // Whether or not to display the 'name'. Changing it to false will suppress the name.
'id' => 'field_id', // Change this so it is unique to you project. Each field id MUST be unique.
'type' => 'text', // This is the field type being added.
'size' => 'regular', // This can be changed to one of the following: 'small', 'regular', 'large'
),
),
);
cnMetaboxAPI::add( $atts );
}
Hope that helps!
