Support Forum
Support › Meta Box AIO › WYSIWYG Not Working Properly
Hello! I am having a couple of issues with the WYSIWYG custom field.
In one CPT/custom field, the WYSIWYG is not saving the "p" tags when pressing enter/return using the visual editor. This means, when I dynamic insert the data on a page, it is create one large paragraph, instead of multiple paragraphs. The only way I can get it to work is by switching to the text editor and manually putting in the open and close "p" tags. These should automatically be input when using enter/return on the visual editor.
on another CPT/custom field, the WYSIWYG is completely broken. It shows I am viewing the visual editor, but none of the edit buttons are visible. In addition, the content box is blank, I can not type in the editor, and I can't click to switch to the text editor view. It simply does not work. If I switch this custom field to a Text Area, I can then see my typed text is still there, but as soon as I switch it back to the WYSIWYG option, I am back to the same issue.
Hi Alisha,
Can you please share the code that creates the fields on your site? Refer to this documentation to generate PHP code https://docs.metabox.io/extensions/meta-box-builder/#getting-php-code
Here is the code for the WYSIWYG fields that are not saving the p tags:
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Lead Magnets', 'your-text-domain' ),
'id' => 'lead-magnets',
'post_types' => ['resources'],
'context' => 'after_title',
'fields' => [
[
'name' => __( 'Funnel Pack Name', 'your-text-domain' ),
'id' => $prefix . 'funnel_pack_name',
'type' => 'text',
],
[
'name' => __( 'Lead Magnet Name', 'your-text-domain' ),
'id' => $prefix . 'lead_magnet_name',
'type' => 'text',
],
[
'name' => __( 'Hero', 'your-text-domain' ),
'id' => $prefix . 'hero',
'type' => 'group',
'fields' => [
[
'name' => __( 'Hero Headline', 'your-text-domain' ),
'id' => $prefix . 'hero_headline',
'type' => 'text',
],
[
'name' => __( 'Lede text', 'your-text-domain' ),
'id' => $prefix . 'lede_text',
'type' => 'wysiwyg',
],
[
'name' => __( 'Button Text', 'your-text-domain' ),
'id' => $prefix . 'button_text',
'type' => 'text',
'std' => 'Send Me My Free Guide',
],
],
],
[
'name' => __( 'Main Content', 'your-text-domain' ),
'id' => $prefix . 'main_content',
'type' => 'group',
'fields' => [
[
'name' => __( 'Secondary Headline', 'your-text-domain' ),
'id' => $prefix . 'secondary_headline',
'type' => 'text',
],
[
'name' => __( 'Body Copy', 'your-text-domain' ),
'id' => $prefix . 'body_copy',
'type' => 'wysiwyg',
],
[
'name' => __( 'Bullet Point 1', 'your-text-domain' ),
'id' => $prefix . 'bullet_point_1',
'type' => 'text',
],
[
'name' => __( 'Bullet Point 2', 'your-text-domain' ),
'id' => $prefix . 'bullet_point_2',
'type' => 'text',
],
[
'name' => __( 'Bullet Point 3', 'your-text-domain' ),
'id' => $prefix . 'bullet_point_3',
'type' => 'text',
],
[
'name' => __( 'Bullet Point 4', 'your-text-domain' ),
'id' => $prefix . 'bullet_point_4',
'type' => 'text',
],
[
'name' => __( 'Bullet Point 5', 'your-text-domain' ),
'id' => $prefix . 'bullet_point_5',
'type' => 'text',
],
[
'name' => __( 'Bullet Point 6', 'your-text-domain' ),
'id' => $prefix . 'bullet_point_6',
'type' => 'text',
],
],
],
[
'name' => __( 'Popup', 'your-text-domain' ),
'id' => $prefix . 'popup',
'type' => 'group',
'fields' => [
[
'name' => __( 'Popup Headline', 'your-text-domain' ),
'id' => $prefix . 'popup_headline',
'type' => 'text',
],
[
'name' => __( 'Popup Lede', 'your-text-domain' ),
'id' => $prefix . 'popup_lede',
'type' => 'wysiwyg',
],
],
],
[
'name' => __( 'Cover Image', 'your-text-domain' ),
'id' => $prefix . 'cover_image',
'type' => 'image_advanced',
],
[
'name' => __( 'Fluent Form Data', 'your-text-domain' ),
'id' => $prefix . 'fluent_form_data',
'type' => 'text',
'desc' => __( 'Enter the unique slug for this lead magnet request.', 'your-text-domain' ),
],
],
];
return $meta_boxes;
}
Here is the code for the WYSIWYG field that is completely broken:
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'FAQ', 'your-text-domain' ),
'id' => 'faq',
'post_types' => ['faqs'],
'fields' => [
[
'name' => __( 'FAQ: Answer', 'your-text-domain' ),
'id' => $prefix . 'faq:_answer',
'type' => 'wysiwyg',
],
],
];
return $meta_boxes;
}
Hi,
Thanks for your additional information.
wysiwyg
field under the post type resources
, I see that issue. The wysiwyg
field is not working properly as a subfield in a group. I will inform the development team to check and fix this.Regarding the wysiwyg
field under the post type faq
, the field ID must not include the special characters. Should be only numbers, letters, and underscores (and rarely dashes).
[
'name' => __( 'FAQ: Answer', 'your-text-domain' ),
'id' => $prefix . 'faq_answer',
'type' => 'wysiwyg',
]
Refer to this documentation https://docs.metabox.io/field-settings/#general
I was able to fix the issue with the wysiwyg field under the faq post type. Hopefully there will be a fix quickly for the wysiwyg field as a subfiled in a group. Thank you!