Reputation: 30521
TinyMCE in WP has a great dropdown of format tags everyone uses, but is there a way to add a class to these tags? For example, there can be 2 <p>
tags, one generating the basic <p></p>
and another button (with a custom name) which generates <p class="myclass"></p>
.
Upvotes: 3
Views: 4313
Reputation: 2878
Definitely. Here's a tutorial if you want to do get dirty with the php: http://wp.tutsplus.com/tutorials/theme-development/adding-custom-styles-in-wordpress-tinymce-editor/ the meat of which is in this filter:
add_filter( 'tiny_mce_before_init', 'tuts_mce_before_init' );
function tuts_mce_before_init( $settings ) {
$style_formats = array(
array(
'title' => 'My Style',
'selector' => 'p',
'classes' => 'myclass',
)
);
$settings['style_formats'] = json_encode( $style_formats );
return $settings;
}
and here's a plugin that'll do the work for you: http://wordpress.org/extend/plugins/tinymce-advanced/
Upvotes: 3