Support Forum

How to paste code (HTML/Javascript/CSS) so it doesn't render in a post

VD Vic Dorfman
Vic Dorfman
Member

Hi All,

My forum is of a technical nature and I often need to post HTML snippets, shortcodes, Javascript snippets, etc., to demonstrate various how-to scenarios.

How can I post my code without it rendering?

Best,
Vic

6 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

My recommendation would be to use the tinyMCE rich text editor and install our Syntax Highlighter plugin. So – for example – a small section of php code I have been working with today would display like:

add_action('genesis_meta', 'sp_home_genesis_meta');
function sp_home_genesis_meta() {
    if (is_active_sidebar('content-top-left') || is_active_sidebar('content-top-right') || is_active_sidebar('content-bottom')) {
        remove_action('genesis_loop', 'genesis_do_loop');
        add_action('genesis_loop', 'sp_home_loop_helper');
        add_filter('genesis_pre_get_option_site_layout', '__genesis_return_full_width_content');
    }
}

Supports a variety of languages and, of course, your users can just use the raw code button and cut and paste.

VD Vic Dorfman
Vic Dorfman
Member

I’ve installed this plugin and my TinyMCE editor is active.

But how do I make the Syntax Highlight button appear in my editor?

Here’s my editor:

http://prntscr.com/8e9mqs

And here are my components settings:

http://prntscr.com/8e9mse

Please advise.

Best,
Vic

YS Yellow Swordfish
Yellow Swordfish
Member

It should self-configure. Just in case it did not for some reason, can you check the options at Options > Content Settings – bottom left. Make sure it is checked on to load in the forum editor and has some languages listed.

VD Vic Dorfman
Vic Dorfman
Member

Ah, it doesn’t autopopulate the languages.

Once I selected some languages the button appeared.

Thanks.

YS Yellow Swordfish
Yellow Swordfish
Member

Thanks for letting me know. I will check up on whether it should which might be better.