Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I write code in WordPress? I want to be able to show something like:

function foo()
    return "bar";

Is there a plugin? I installed one called Code Markup, but this doesn't add any code options when I am adding a new post (at least not that I am seeing).

share|improve this question
check this answer here if it's any help webapps.stackexchange.com/questions/7107/… – Lipis Mar 3 '11 at 4:18
also, check out wordpress.stackexchange.com – Michael Pryor Mar 3 '11 at 4:24
There's a codex page on this: codex.wordpress.org/Writing_Code_in_Your_Posts – Vervious Mar 3 '11 at 8:54
Even wordpress.com blogs support sourcecode tags now. en.support.wordpress.com/code/posting-source-code – keheliya Mar 10 '11 at 17:13

I use the SyntaxHighlighter plugin. It works well, is simple to use, and supports a good variety of languages.

See an article on my site for example output.

share|improve this answer

No need for a plugin.

All WordPress Setups come with this option available (unless you change the default setup).

Just enclose it as follows:

<code>function foo()
    return "bar";

You can find it below.

Where is the code ?

share|improve this answer

Suppose I have a code written using Ruby.

In my blog post I would do

[sourcecode language="ruby"]
def hello
  puts "Hi! This is Rohit here"

WordPress has this as a default feature. I haven't used any plugin for this.

share|improve this answer
I will try this out thanks. – JD Isaacks Mar 9 '11 at 14:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.