WordPress source code tag

Default featured post

If you manage your website/weblog with WordPress and frequently use code in your posts, you can easily show your code in especial format nicely with using Syntax Highlighter plugin. This plugin provides its own built in tags which you can utilize them in your posts. In order, to represent code in WordPress using Syntax Highlighter you can use “sourcecode” tag.

Keep in mind that the style of this tag is different from HTML tag. Code/Sourcecode tag is surrounded by [ and ] character. Following example shows how to use it.

['sourcecode']

Your source code should be placed here.

['/sourcecode']

Note: code tag and sourcecode tag are similar to each other and you can use one instead of the another.

Both sourcecode and code tags support following syntax.

  • 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

If you do not set language, it is set to text by default.

Sourcecode tag has many options which you can set such as highlight, first line, etc.

More information can be found in official web page of WordPress.