In my Wordpress post I click on edit post and skip over to the html editor tab and click on it. I have a pre on that page and when i give it a rel and publish its all fine but when I skip back over to visual editor it just takes out the rel attribute.

  • Why do you want to add an invalid attribute to pre? rel is for links.
    – fuxia
    Apr 8, 2012 at 22:23

1 Answer 1

function extend_tinymce( $values ) {
    $elements = 'pre[id|class|title|rel]';
    if ( isset( $values['extended_valid_elements'] ) ) {
        $values['extended_valid_elements'] .= ',' . $elements;
    } else {
        $values['extended_valid_elements'] = $elements;
    return $values;
add_filter('tiny_mce_before_init', 'extend_tinymce');

The above snippet is what I use for example, of course you can extend this beyond id, class, title, rel, to things such as height, width, style, name, etc...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.