Write code in your wordpress page

[banner]

Sometimes you want to put code in your wordpress blog. The beste way to write code is switch to switch to HTML and put the <code> and </code> tags to your post.

Example with <code>:


mailq | tail -n +2 | grep -v '^ *(' | awk  'BEGIN { RS = "" } { if ($7 == "[email protected]") print $1 } ' | tr -d '*!' | postsuper -d -

Example withoute <code>:

mailq | tail -n +2 | grep -v ‘^ *(‘ | awk  ‘BEGIN { RS = “” } { if ($7 == “[email protected]”) print $1 } ‘ | tr -d ‘*!’ | postsuper -d –

You will see that some characters won’t display correctly if you don’t use the code tag.

Another/better way to publish code is using the “SyntaxHighlighter Evolved” plugin.

Example:

mailq | tail -n +2 | grep -v '^ *(' | awk  'BEGIN { RS = "" } { if ($7 == "[email protected]") print $1 } ' | tr -d '*!' | postsuper -d -

And if you need special characters in your post try these:

< = &lt;
> = &gt;
/ = &#47;  	
] = &#93;
[ = &#91;
" = &#34;
' = &#39;

And if you want to use a code language try these

[code language="sql"]
your code here
[/code]

The following languages are supported:

actionscript3
bash
clojure
coldfusion
cpp
csharp
css
delphi
erlang
fsharp
diff
groovy
html
javascript
java
javafx
matlab (keywords only)
objc
perl
php
text
powershell
python
r
ruby
scala
sql
vb
xml

SQL script Example:

USE database;
SELECT * FROM Persons
WHERE City='Sandnes'

Last but not least. DO NOT USE THE VISUAL VIEW 🙂 Visual will scramble your code.

[banner]

Author: Thomas Faddegon

Do you like my posts and want to do something back? You can buy me a beer :)