I'm using the following code in functions.php to add a TinyMCE box on custom field textareas inside the Editor:

function FT_TinymceCustom()
<script type="text/javascript">
        var i=1;
        $('.customEditor textarea').each(function(e)
            var id = $(this).attr('id');

            if (!id)
                id = 'customEditor-' + i++;

            tinyMCE.execCommand('mceAddEditor', false, id);


However, on any box I add this to, it seems to cause a bug that deletes paragraph tags.

So if I enter this in the custom TinyMCE textarea (source view):


After saving, this is what shows in the box:

p>test test</p>

This only occured after the latest 3.9 update, which forced me to modify my JS code above to make it work.

  • Ya i also have the same problem with <p></p> tag and if u set image between the text it will show anchor tag not the image
    – ksr89
    May 25, 2014 at 4:34

2 Answers 2


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)


Found the answer here: https://stackoverflow.com/questions/5956174/tinymce-editors-in-meta-boxes-not-saving-p-tag

You must run wpautop() on the output of the tinymce.

  • Thanks for posting your own solution to your problem. The only problem is that your answer will be useless if this link gets removed in future (this is not a WPSE link, so we have no control over that). Please edit your answer and add the relevant info from that link to your answer. You must just keep the link for credit purposes to credit the person who posted the solution on Stackoverflow. May 25, 2014 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.