Since that SO link is to my question, I will re-post it and expand on it here.
TinyMCE does NOT save “p” tags in the editor, instead linebreaks and the like are converted into p tags by WordPress functions (such as wpautop()
. So the solution was a combination of altering my textbox to look like:
<textarea class="wysiwyg" rows="10" cols="50" name="some_textarea" rows="3"><?php echo wp_richedit_pre($value); ?></textarea>
Then on the frontend to re-apply all the default filters that are added to the_content
.
// in functions.php
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');
and then where you need to print the info:
echo apply_filters( 'meta_content', $data );
You could apply the content filters directly, but I find that a lot of plugins add content to that as well and I ended up with social sharing buttons everywhere and so came up with this solution.
You can check my github for repeatable, sortable, tinyMCE-enabled text editors (using WP Alchemy, but I think the JS could be adapted for use without WPA)