WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    
Why do you want to add an invalid attribute to pre? rel is for links. – toscho Apr 8 '12 at 22:23
up vote 2 down vote accepted
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...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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