Category Archives: Wordpress

Adding code snippets to WordPress post

Probably the easiest way to add nice code lines to a post is to use some plug-in like Crayon Syntax Highlighter or SyntaxHighlighter Evolved.

codehighlighterMy favourite is Crayon Syntax Highlighter. Good thing is that there are lots of options available. Bad thing is, that there are for the first time too many options available. It means there is a bit of learning curve. You have to play a bit with it.

The code is inserted (copy pasted) in a editing window.  Here is an example of Hello World in c-language.

The second choice called SyntaxHighlighter Evolved is used by writing the tags direct with WordPress text editor. You should not use Visual mode editing, while it might remove the code tags. Remember that code begins with [ code ]-tag do not use < code > -tags!. You can add some variables like language. The code

will produce

main( )
printf("hello, world\n");