I was looking for a simple way to show/highlight the code portion of my blog. The regular <pre> tags didn’t do it for me. It just didn’t look professional.
After a quick search, I came across a WordPress plugin called WP-Syntax.
“WP-Syntax provides clean syntax highlighting using GeSHi — supporting a wide range of popular languages. It supports highlighting with or without line numbers and maintains formatting while copying snippets of code from the browser.”
There are a few ways of using this plugin, but I will only be using two.
The first way is when I want to highlight commands:
All I need to do is add a <pre lang=”php”> at the beginning of my command and add a </pre> at the end.
The second way is when I want to highlight code:
I wanted a number next to each line of code. This will help me identify a bad piece of code if someone wanted to point it out. For example, someone would easily be able to tell me that line 5 had an error in it.
All I need to do is add a <pre lang=”php” line=”1″> at the beginning of my command and add a </pre> at the end.
example code example code example code example code example code example code