How to Post Source Code on

Since most of the posts in this blog are programming related, I need to post source code from time to time. I’ve been trying to find a way to post source code in such that it will be syntax highlighting and all the goodies.

I tried to use the “/code” tag in the wordpress editor, but it outputs in some awkward font.


/Code button will insert around the text. The font chosen by this theme is not legible.

int main()
std::cout<<"You can't read me anyway"<<std::endl;
return 0;

Use the Sourcecode Tag

So after some googling, I finally found a support page in wordpress. Apparently all you have to do is to wrap your source code in

[sourcecode language=”???”] [/sourcecode]

Replace ??? with the language of your choice. For example, C++ will use “cpp”.  See the support page for the complete list.

#include <iostream>
int main()
   std::cout << "Ah, much better" << std::endl;
   return 0;


It is quite simple!

One thought on “How to Post Source Code on

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s