wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Allow more HTML tags in the editor

wordpress snippet

By default the wordpress editor does not allow some tags and will strip them out. Adding this snippet to the functions.php of your wordpress theme will enable you to use HTML tags like iframe, name, class etc…

snippet :  PHPcopy
function fb_change_mce_options($initArray) {
	$ext = 'pre[id|name|class|style],iframe[align|longdesc| name|width|height|frameborder|scrolling|marginheight| marginwidth|src]';
	if ( isset( $initArray['extended_valid_elements'] ) ) {
		$initArray['extended_valid_elements'] .= ',' . $ext;
	} else {
		$initArray['extended_valid_elements'] = $ext;
	return $initArray;
add_filter('tiny_mce_before_init', 'fb_change_mce_options');
source →

Did you like this post? If so please share it with your friends. Thanks!

  • begs

    Thanks for this one.
    Anyway: I wanted to ask if there is a way to limit the allowed tags in the content, because i have “author” users, who should not e.g. add inline styles or use table, pre or h[1-x] tags…