Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using the TinyMCE Advanced plugin so that I can add my own custom styles to the Style dropdown in the Visual Editor. However, I don't want some of the styles that are included in the style.css file to be listed there, as they are 'internal' classes (for aligning pictures etc).

Is there a way to stop these classes being shown in the dropdown? Either by changing the TinyMCE Advanced configuration, or by editing the CSS file in a certain way?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

This should be what you're looking for - put this code into your theme's functions.php file:

add_filter( 'tiny_mce_before_init', 'yourprefix_tiny_mce_before_init' );
function yourprefix_tiny_mce_before_init( $init_array ) {

    // filter styles:
    $init_array['theme_advanced_styles'] = "your_style=your_class";

    // filter formats:
    $init_array['theme_advanced_blockformats'] = "p,h3,h4,h5";

    return $init_array;
}

This way the only style that will be displayed is your_style.

The 3rd line is taking care of tinymce formats - might be useful too.

See Plugin_API/Filter_Reference/tiny_mce_before_init for more informations and examples.

share|improve this answer
    
Great! Is there documentation for these options anywhere? For example, how would I let multiple styles through? –  robintw Jan 10 '11 at 19:46
    
use semicolon: $init_array['theme_advanced_styles'] = "your_style=your_class;another_class=your_class2"; google 'tiny_mce_before_init' for more .) –  Michal Mau Jan 10 '11 at 19:56
    
related: wordpress.stackexchange.com/questions/4349/… –  Michal Mau Jan 10 '11 at 19:58
add comment

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.