In the text editor, where you can set headings and other settings, is it possible to add your own styles for clients to use? and even remove the unnecessary ones?
Leave a Reply
You must be logged in to post a comment.
In the text editor, where you can set headings and other settings, is it possible to add your own styles for clients to use? and even remove the unnecessary ones?
You must be logged in to post a comment.
The “classic” TinyMCE editor has two dropdowns:
formatselect
for paragraph styles andstyleselect
for character styles – which can also contain paragraph styles, to make it more confusing. The configuration in WordPress by default only shows the format dropdown. If you apply a custom stylesheet to the editor, TinyMCE can use it to pick up the classnames and add them to the style dropdown – but this did not work every time for me.Since 3.0 you can call
add_editor_style()
in yourfunctions.php
to add a stylesheet to the editor. By default it’seditor-style.css
in your theme directory. Before 3.0 you have to hook into themce_css
filter to add the URL to your editor stylesheet. This will end up in thecontent_css
TinyMCE configuration value.To add the style dropdown, the
styleselect
option must appear in one of the button bar configuration arrays (theme_advanced_buttons[1-4]
in TinyMCE, filtered bymce_buttons_[1-4]
in WordPress). The list of block formats is controlled by thetheme_advanced_blockformats
option of TinyMCE, which you can add to the control array in thetiny_mce_before_init
filter. If you want to customize the names of the style dropdown (not just your CSS class names), look at thetheme_advanced_styles
option. You can also use the more advancedstyle_formats
option which gives you more flexibility to define the styles.The relevant PHP code with all the hooks and default configuration is in
wp-admin/includes/post.php
, in functionwp_tiny_mce()
. All together, your setup could look like this:You can add custom format or remove exist in that way:
See more in this post and this tinymce docs
As per here TinyMCE format dropdown no longer showing style previews
Kara had it right, you need to unset the default styles to see the new styles…