Custom Metaboxes and Fields (CMB) will create metaboxes and forms with custom fields that will blow your mind. This is version 2.0 and has been completely rewritten.
$cmb = new_cmb2_box( array(
'id' => $prefix . '09b_metabox',
'title' => __( '09B - WYSIWYG', 'cmb2' ),
'object_types' => array( 'page', ), // Post type
'show_on' => array( 'key' => 'page-template', 'value' => 'templates/uikit.php' ),
'context' => 'advanced',
'priority' => 'high',
'show_names' => true, // Show field names on the left
) );
// Regular text field
$cmb->add_field( array(
'name' => __( '', 'cmb2' ),
'id' => $prefix . '09B_wysiwyg_content',
'type' => 'wysiwyg',
) );
$cmb->add_field( array(
'name' => __( 'Remove padding', 'cmb2' ),
'id' => $prefix . '9B_less_padding',
'type' => 'checkbox',
) );
HI. I have setup an admin page and am using CMB2 to store the field information.
I used the code from the snippet library to do this. have done this dozens of times for sites. Usually is the easiest way to create admin controls. Never seen this issue.
I have 2 WYSIWYG fields on this page. All of the fields work and store data, but formatting only saves for the first WYSIWYG on the page.
when I save the admin page it refreshes and the content is still there, but all formatting is stripped from the second box.
Any Ideas?
<?php
$post_type_name = PREFIX . 'inducao';
$singular_label = 'Inducao';
$plural_label = 'Inducoes';
$slug = 'inducao';
$type = new CPT(
array(
'post_type_name' => $post_type_name,
'singular' => $singular_label,
'plural' => $plural_label,
),
array(
'supports' => array('title', 'thumbnail','multicheck'), // https://codex.wordpress.org/Function_Reference/post_type_supports
'has_archive' => true, // Define se o post type irá ser exibido no frontend do WordPress
'rewrite' => array('slug' => $slug), // Define como a URL do post type
'hierarchical' => true,
'capability_type' => 'page',
'labels' => array(
'all_items' => 'Todos ' . $plural_label,
'add_new' => 'Adicionar novo',
'add_new_item' => 'Adicionar novo ' . $singular_label,
'edit_item' => 'Editar ' . $singular_label,
'new_item' => 'Novo ' . $singular_label,
'view_item' => 'Ver ' . $singular_label,
'search_items' => 'Procurar ' . $singular_label,
'not_found' => 'Nada encontrado',
'not_found_in_trash' => 'Nada encontrado no lixo',
'options' => array(
'check1' => 'Check One',
'check2' => 'Check Two',
'check3' => 'Check Three',
),
)
);
// Icon
$type->menu_icon("dashicons-admin-tools
"); // https://developer.wordpress.org/resource/dashicons