WP register_post_type() with custom CMB2 meta box

functions.php
register_post_type('portfolio',[
'labels'=>[
'name'=> 'Portfolio',
'add_new_item'=>'Add new portfolio',
'view_item'=>'View portfolio',
],
'public'=>true,
'menu_icon'=>'dashicons-edit',
'menu_position'=>1,
'supports'=> ['title','editor','thumbnail']
]);

custom.php
add_action('cmb2_admin_init','custom_metaboxes');

function custom_metaboxes(){
$portfolioMetaBox = new_cmb2_box([
'object_types'=>['portfolio'],
'id'=>'portfolio-additional-fields',
'title'=>'Portfolio Additional Fields'
]);

$portfolioMetaBox->add_field([
'id'=>'portfolio_designation',
'name'=>'Portfoilo Designation',
'type'=>'text'
]);

$portfolioMetaBox->add_field([
'id'=>'portfolio_details',
'name'=> 'Portfolio Details',
'type'=> 'wysiwyg',
'options'=> [
'textarea_rows'=> get_option('default_post_edit_rows',3)
]
]);
}

Comments

Popular posts from this blog

Deploy laravel application to digital ocean droplet

Git post receive setup at server for git push to the production from local machine