Monday, October 1, 2012

Allow more HTML tags in the editor

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…

function jb_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', 'jb_change_mce_options');

No comments:

Post a Comment