Posting source code in WordPress blogs
April 19, 2012 1 Comment
In my previous blog post, I published the source code of a bash shell script. I noticed that WordPress kept on messing around with the code (like replacing some of the double quotes), and at first I didn’t know how to solve this (I’m quite new to WordPress).
And then I found the following support article:
So, basically, you need to wrap your source code into “sourcecode” blocks, using the HTML editor.
There are also some nice options, like setting the language, enabling highlighting or line wrapping etc.
This is an example with sourcecode language=”bash” as option:
#!bin/bash # description: source code example echo "hello world!" exit 0