views:

506

answers:

6

Hi,

got a new blog at wordpress few days ago (http://ghads.wordpress.com) and I want to post some code snippets now or then. Is there anyway to make it look like code without paying for extra plugins? Thanks a lot!

+19  A: 

See here: http://faq.wordpress.com/2007/09/03/how-do-i-post-source-code/

Wrap your code in these tags: [sourcecode language='css']..[/sourcecode]

Available language codes:

  • cpp
  • csharp
  • css
  • delphi
  • html
  • java
  • jscript
  • php
  • python
  • ruby
  • sql
  • vb
  • xml

Hope that helps.

AlexDuggleby
This page shows all the supported languages: http://en.support.wordpress.com/code/posting-source-code/
Josh Brown
A: 

There's a <code> html element you can use. Otherwise you could try the Textile or Markdown syntaxes (I'm not sure if WordPress.com uses them). Try it out and use the preview function in WordPress to see when you get it right.

Christian Davén
A: 

Thanks a lot, exactly what i've been looking for! I really didn't find infos yesteday by googling and looking at wordpress! Thank you Alex and StackOverflow.com!

GHad
A: 

If you are hosting your own wordpress blog opposed to on WP.com you can get this functionality by installing this plugin, since it is the same plugin that the WP.com code relies on.

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

danmayer
A: 

You can also use the new web app I wrote called BlogTrog CodeWindow -- it's powered by Actipro CodeHighlighter.

http://www.blogtrog.com

It's free, should work in all modern browsers, and doesn't require you to install anything anywhere. Just paste your code and embed the results.

Elmo Gallen
A: 

Thx i was looking for this

metal-gear-solid