Question

I write a programming blog, so sometimes I just have to write a word to represent a command or function which I like writing between the code tags. (See, what I just did there).

So, just like StackExchange has the "code" button, is there a plugin to add this button to the visual editor? I know I got it on the HTML editor, but I rarely use it.

I was thinking of writing a plugin for this, but just in case I'm asking first in case anyone knows of a plugin doing this already.

Was it helpful?

Solution

There seem to be a few people scratching this itch over at the TinyMCE sourceforge tracker. http://sourceforge.net/tracker/?group_id=103281&atid=738747

This looks promising.. "CodeExtras adds <var> and <code> markup buttons - ID: 2904557" http://sourceforge.net/tracker/?func=detail&aid=2904557&group_id=103281&atid=738747

OTHER TIPS

I haven't tested this code, but I think it should work:

add_filter('mce_buttons','rw_mce_buttons');
function rw_mce_buttons($mce_buttons) {
    $mce_buttons[] = 'code';

    return $mce_buttons;
}

You can press Shift+Alt+X when you have hovered the text.

All Wordpress Editor keyboard shortcuts: https://danigeorgiev.com/wordpress-editor-tinymce-keyboard-shortcuts/

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top