WordPress comes equipped with a powerful visual editor called TinyMCE. This utility is itself a separate opensource project maintained and developed by MoxieCode Systems. TinyMCE is a powerful, platform independent, javascript based WYSIWYG editor. Apart from WordPress, it is used in my other content management systems.

TinyMCE is like your regular rich text editors with lots of buttons to do different things. It is extendable just like WordPress and can be used to provide an extended user interface to users for writing posts. Most of the advanced buttons are hidden in the default WordPress Visual Editor. You can display the full range of buttons by switching to the Advanced Editor Mode.

Hint: Use Shift+Alt+Z to display all buttons in Visual Editor or click the Show/Hide Kitchen Sink button

Why Would You Want to Customize TinyMCE

As a WordPress developer or site owner, there will be times when you will have users other than yourself contributing content on your website. Not all of them will be familiar with your editorial style. Sometimes you will even have contributors who do not even know how to make a hyperlink in HTML editor.

So as a website admin/developer it is your job to make it simpler for them to follow your editorial style by providing them an interface where they can easily use the same styles as you want them to. Websites that have a lot of non-tech savvy contributors will benefit a lot if they customized their TinyMCE editor in WordPress. This will provide a consistency in style, content would look better, and the contributors will be able to focus on just writing.

In this example we will be adding a Styles drop down menu to TinyMCE, then we will add a purple button to it, and another element for writing tag lines. At WPlift we use that purple button to highlight links to external sites and downloads. So I thought it would be fun learning how it can be added to TinyMCE.

How to add Custom Styles to WordPress Visual Editor

Firstly, we are going to enable Styles dropdown menu for TinyMCE in our WordPress edit screen.

What we have done here is that we have enabled the Styles Menu. The above code will show the default style classes available. We don’t want default classes to confuse our user so we add our own classes to it with friendly titles.

Now we have added a menu with two style items in it, Tag Line and button. However, nothing happens when a user selects text and then selects these options from the menu. So we need to define these styles in our Editor Style Sheet and our Theme Stylesheet.

Since version 3.0, WordPress allows theme developers and website admins to define custom styles for the Visual Post Editor. This means that theme developers can provide the same style for the visual editor as their themes and when a user is writing a post they know how it will look when published. This feature makes the TinyMCE in WordPress truly a WYSIWYG editor.

Using add_editor_style we add these styles and tell WordPress where to look for the CSS for these styles. The default location is editor-style.css, you can create this file in your theme directory if it does not already have it. Or you can use a custom style sheet of your own.

Show and Hide Buttons in TinyMCE

The default settings for the TinyMCE buttons and plugins are saved in /wp-includes/class-wp-editor.php. These settings can be over written by using the filter tiny_mce_before_init. There are several buttons in the visual editor which many people never use and you can remove these buttons if you want. Look at the following code and see if there are things that you don’t want. Also notice that you can add a third and fourth row of buttons to your Visual Editor UI.

Creating TinyMCE Custom Buttons in WordPress

Just like WordPress, TinyMCE is also extendible by using plugins. There are some tinyMCE plugins available in /wp-includes/js/tinymce/plugins directory, which you can look at if you want to write a plugin for yourself. Also look at the TinyMCE documentation on creating a plugin. These plugins can be embedded into the UI of your Visual Editor in WordPress.

However, creating TinyMCE plugins for WordPress is not a very simple task. For users who don’t want to dive into writing plugins there are some excellent WordPress Plugins that allow you to extend TinyMCE in WordPress.

Ultimate TinyMCE Plugin

The Ultimate TinyMCE plugin is a powerful WordPress plugin that extends your TinyMCE editor to the maximum level. It comes loaded with lots of buttons which will make it a lot easier for MSWord users to create their posts in Visual Editor. I particularly liked the YouTube Button, which allows users to set the width and height, along with other options. However, there are some buttons that many would find useless and these buttons can be disabled from the plugin settings page.

TinyMCE Template Plugin

TinyMCE template plugin is a very useful tool for the websites where authors are required to follow a format and style guide to contribute content. TinyMCE Template plugin allows you to create template posts which you can use inside your visual editor to create new posts. The idea is so simple and beautiful and works flawlessly. You can create templates, predefine required fields which post authors can then fill in quickly and move on.

TinyMCE Advanced

Oli has previously written a thorough review of this plugin in his post How to Extend WordPress Visual Editor Buttons, so I will keep this one short. As the name says this plugin adds extra features to the Visual Editor in WordPress. One feature that I particularly found useful was the ability to load CSS classes from the theme’s style sheet and make them available in Visual Editor. The plugin settings page has a drag and drop interface to set buttons, add separators between them, and modify the editor to meet your needs.

Conclusion

Using custom styles with TinyMCE can make it a lot easier and quicker for users to create buttons, format content, and stylize posts quickly. It does not completely eliminate the need for switching to HTML editor from time to time, but it can be great tool for users coming from desktop publishing environment who just want to write posts not code.

(No Ratings Yet)

Disclosure: This page may contain affiliate links for which we will receive compensation if a purchase is made via the link.

Pages

About WPLift

Wplift was founded in September 2010 by Oliver Dale, the founder of Kooc Media, to help people with WordPress by providing tutorials, theme roundups,
plugin guides and general WordPress news. Since then the blog has grown exponentially & now reaches hundreds of thouands of WordPress users each month.