WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

I've got a WordPress blog on WordPress.com. When posting something I'm including some sample Java code in the <code tags, is there any way I can have this formatted better? Such as syntax highlighting and line numbers etc?

An example of what I have is here, even though I have the code tags it doesnt seem to make it any more readable than normal text

Am I limited in choices as I've gone for the free option?

share|improve this question
I assume you mean wordpress.com as "the wordpress site". – hakre Sep 4 '10 at 12:10
@hakre: There you go again with the improper casing of the trademarked term WordPress. I know you think it's a statement but it makes you (and the site) look sloppy. – MikeSchinkel Sep 4 '10 at 19:14
@MikeSchinkel: From what I see in the revision history, I never edited that answer. – hakre Feb 3 '11 at 11:35
up vote 7 down vote accepted

wordpress.com supports code syntax-highliting. You can read all about it here: http://en.support.wordpress.com/code/posting-source-code/

for your specific example use:

[sourcecode language="java"]
package com.jameselsey.domain;

import java.util.ArrayList;
import java.util.List;
import com.google.android.maps.GeoPoint;
import android.app.Application;

* This is a global POJO that we attach data to which we
* want to use across the application
* @author James Elsey
public class GlobalState extends Application
private String testMe;

public String getTestMe() {
return testMe;
public void setTestMe(String testMe) {
this.testMe = testMe;
share|improve this answer
You can use "lang" instead of "language" if you're into the whole brevity thing. – Mr_Chimp Jun 15 '11 at 13:45

Yes you can. It's [code] *your code here* [/code] and you can even hint the language: [code lang="php"]<?php echo 'test'; ?>[/code].

This is the method I prefer (quick to write). There seem to be other ways as the following resource explains: Support: Code » Posting Source Code (wordpress.com)

share|improve this answer

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.