HTML5, WordPress and Tiny MCE issue – wrapping anchor tag around div results in funky output

[*]

You need to modify the TinyMCE settings, specifically the valid_children setting. To accomplish this in WordPress, use the tiny_mce_before_init filter reference.

Something like this (untested):

add_filter('tiny_mce_before_init', 'modify_valid_children');

function modify_valid_children($settings){
    $settings['valid_children']="+a[div|p|ul|ol|li|h1|h2|h3|h4|h5|h5|h6]";
    return $settings;
}

You may be able to use +a[*] to capture all elements, but you’ll want to take care to avoid nested anchor tags.

[*]

Leave a Comment