This may not solve the problem, but I hope it helps you.
-
In the
sky_post_excerpts()function, I used this to display the TinyMCE/classic editor: (the$dataisget_post_meta($post->ID, 'skyscraper_post', true))<?php wp_editor( $data, 'post_meta_box', array('textarea_name'=>'skyscraper_post')); ?> -
In the
post_meta_box_save()function, I saved the meta like so, where$allowediswp_kses_allowed_html():update_post_meta( $post_id, 'skyscraper_post', wp_kses( $_POST['skyscraper_post'], $allowed ) ); -
On the front-end, I display the metadata like so:
// This is really just an example. And I was on a single post. echo get_post_meta( get_the_ID(), 'skyscraper_post', true );
And everything worked well for me — all HTML remained as generated by the TinyMCE editor.
UPDATE
if I use visual not text in TinyMCE then the p tags doesn’t show
wp_kses_allowed_html() when called without specifying the $context parameter, will use the global variable $allowedtags which is an array of KSES allowed HTML elements, which (by default) do not include p tags/elements.
If you want to allow p elements, you can:
-
Use
wp_kses_allowed_html( 'post' )which will use the global variable$allowedposttagswhich also holds similar array as the$allowedtagsvariable, but$allowedposttagshas many elements allowed includingtableandvideo. -
Or manually enable the
pelements:$allowed = wp_kses_allowed_html(); $allowed['p'] = array(); // allows all attributes! -
Same as above, but build your own allowed tags:
$allowed = array(); $allowed['p'] = array(); // allows all attributes!
But, you shouldn’t allow all attributes.. so:
$allowed['p'] = array(
'class' => true,
'id' => true,
...other attributes...
);