Using my WordPress theme functions file, I have created a custom meta text area (please see screenshot below).
The custom meta text area is displayed when editing a page.
It all works great saving and changing the text, but if i change a certain part of the paragraph text to heading2 and click save, it reverts the heading2 back to paragraph.
My functions update post meta box looks like the following:
if( isset( $_POST['my_meta_box_text_challengetbl'] ) )
update_post_meta( $post_id, 'my_meta_box_text_challengetbl', wp_kses( $_POST['my_meta_box_text_challengetbl'], $allowed ) );
}
The $allowed php code looks like the following:
$allowed = array(
'a' => array( // on allow a tags
'href' => array() // and those anchords can only have href attribute
)
);
Please update…
This will allow H2 to be used, note: you can add in any other html tags you want allowed here as well. Check out https://codex.wordpress.org/Function_Reference/wp_kses for more info.