As mentioned in the comments, this is a lack of wp_autop()
and other formatting functions that get applied to the the_content
filter. The editor does not save <p>
tags at all, but later on line-breaks are converted into paragraphs via wp_autop()
.
For meta content, I like to recreate the default filters. I do this because some plugins add things via the the_content
filter, Once I had apply_filters('the_content', $your_meta_content);
for all my meta fields and ended up with 20 sets of social sharing buttons.
/*
* Recreate the default filters on the_content
* this will make it much easier to output the meta content with proper/expected formatting
*/
add_filter( 'meta_content', 'wptexturize' );
add_filter( 'meta_content', 'convert_smilies' );
add_filter( 'meta_content', 'convert_chars' );
add_filter( 'meta_content', 'wpautop' );
add_filter( 'meta_content', 'shortcode_unautop' );
add_filter( 'meta_content', 'prepend_attachment' );
add_filter( 'meta_content', 'do_shortcode');
Then where you actually wish to display your new data, you should write the following:
$description = get_post_meta($post->ID, 'sdm_description', true);
echo apply_filters( 'meta_content', $description );