How to add “code” format button to Tinymce 4 in WordPress 3.9

Tinymce offers an inline code formatting option that wraps the <code> tag around content. But WordPress does not include this. I think that there must be an easy way to enable it. I have seen discussing on how to do this in earlier versions of WP (with Tinymce 3) in threads like Add “code” button to wordpress tinyMCE ,
but I can’t see how to “translate” this into Tinymce 4.

I tried the following. It gives me the Source Code but not the code tag.

Read More
// Add <code> support to the Visual Editor
// Load the code TinyMCE plugin

function my_TinyMCEplugins($plugin_array) {
   $plugin_array['code'] = get_bloginfo('template_directory') . '/inc/code/plugin.min.js';
   return $plugin_array;
}
add_filter('mce_external_plugins', 'my_TinyMCEplugins');

// Add the code button into the toolbar

function my_TinyMCE($in) {
   $in['toolbar2'].=',code';
 return $in;
}
add_filter('tiny_mce_before_init', 'my_TinyMCE' );

Thanks for any help!

Related posts

Leave a Reply

1 comment