How to insert code into wordpress

What you are looking for is some kind of syntax highlighter. Where the code shows up in your post in a box with the number of lines, etc, correct?

There are some plugins in wordpress for that.

Check out:

http://wordpress.org/extend/plugins/syntaxhighlighter/

http://wordpress.org/extend/plugins/crayon-syntax-highlighter/

Hope it helps. Cheers


Sorry to say, but with following code you mentioned WONT WORK

[sourcecode language="csharp"]
//your code comes here
[/sourcecode]

So, on Wordpress Site to add Code snippet to the wordpress blog is:

[code language="javascript"]
//your language script here
[/code]

Hope this helped you! :)


If you are running your blog on Wordpress.com, you just include the following lines before your code.

[sourcecode language="csharp"]
//your code comes here
[/sourcecode]

Wordpress.com gives us the facility to avoid worrying about code highlighting. If your code is in between these blocks then it will automatically render as per the language you specified. It can support many languages.

Some of them are..

html

javascript

java

javafx

matlab (keywords only)

objc

perl

php

If you have a self-hosted site, or one hosted on wordpress.org, you should should use the SyntaxHighlighter plugin: wordpress.org/plugins/syntaxhighlighter.

This is the plugin the WordPress team sourced to create this functionality on wordpress.com

For more information see this link

Tags:

Wordpress