WYSIWYG custom field does not preserve HTML formatting

I created a custom WYSIWYG exchange that I created using the wp_editor function and passed in the appropriate settings. My problem is that when I enter text in the box, I try to format and save the text with headers, uls, etc., it won't keep the formatting. See screenshot and code below:

enter image description here

<?php 

    function theme_meta_box_services_callback($post) {
    $service_details = get_post_meta($post->ID, 'service_details', true);

    $settings_editor = array(
        'quicktags' => true,
        'tinymce' => true,
        'textarea_rows' => 8,
        'media_buttons' => true
    );

    wp_editor(esc_attr($service_details), 'service_details', $settings_editor);

    }
?>

      

I tried to use the "esc_html" function instead of the "esc_attr" function, but it still didn't work.

Any help would be greatly appreciated. - Jim.

+3


source to share


1 answer


Update



Removed esc_attr () function and formatting done.

+2


source







All Articles