title

Allow more HTML tags in the editor

 

Allow more HTML tags in the editor

11 Mai 2013, Posted by antoine in

By default, WordPress editor doesn’t allow HTML tags which aren’t compliant with the XHTML 1.0 standard. However, the code shown below will force the editor to accept more tags. You can paste it into your theme’s functions.php file, save it, and the function is good to go.

function fb_change_mce_options($initArray) {
    // Comma separated string od extendes tags
    // Command separated string of extended elements
    $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;
    }
    
    // maybe; set tiny paramter verify_html
    //$initArray['verify_html'] = false;
    return $initArray;
}
add_filter('tiny_mce_before_init', 'fb_change_mce_options');