Google Code Prettify for wordpress

This small wordpress plugin enable syntax highlighting of code snippets in your post using Google Code Prettify.

Notice: you will need to have JavaScript enabled in your browser for this to work.

I had developed another Source Code syntax highlighting plugin using Geshi before,but they are totally different things.with Geshi,code is parsed on the server side,no javascript is needed.

It’s hard to say which is the better,choose one based on your own needs.

Download Google Code Prettify for wordpress v1.1


This plugin requires WordPress v.2.0 or later.

  1. unzip and upload the files to your wp-content/plugins/ directory.
  2. Activate the plugin by logging into your WordPress administration panel, going to ‘Plugins’, then clicking the  ‘Activate’  button for  ‘Google Code Prettify’.
  3. Done,enjoy it.


Put code snippets in <pre class="prettyprint">…</pre> or <code class="prettyprint">…</code> and it will automatically be pretty printed.




# Fibonacci numbers
# Writes an infinite series to stdout, one entry per line
function fib() {
  local a=1
  local b=1
  while true ; do
    echo $a
    local tmp=$a
    a=$(( $a + $b ))

# output the 10th element of the series and halt
fib | head -10 | tail -1

More examples

FAQ (from

  1. Which languages does it work for?
    The comments in prettify.js are authoritative but the lexer should work on a number of languages including C and friends, Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk and a decent subset of Perl, but, because of commenting conventions, doesn’t work on Smalltalk, Lisp-like, or CAML-like languages.
  2. How do I specify which language my code is in?
    There’s no way to tell it which language because would complicate the interface. If it doesn’t guess the language properly, that’s a bug.
  3. Which browsers does it work with?
    It’s been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4. Look at the test page to see if it works in your browser.

119 thoughts on “Google Code Prettify for wordpress”

  1. Pingback: Plugins.Net.Ru
  2. Pingback: new.chaos
  3. You should create a new release for wordpress 2.2 or document the need to call wp_head() before the code blocks, I had to read through the source code to find out my theme was not calling the function used to execute the plugin’s gcp_head() function.

    I made changes while troubleshooting the problem, which might be of interest to some of you:

    function gcp_head() {

    This will use prettify.js and prettify.css directly from the google-code-prettify’s subversion trunk. Beware if you don’t trust this branch to be stable and use a release branch instead. However the purpose behind using trunk is to benefit from possible future updates in this nice javascript code prettifying commodity.

    Enjoy :-)

  4. Sex Shop,Sex,Erotic Shop,Erotik Market,Seks Shop,Sexshop,Erotic Shop,Azdırıcı damla, Cinsel Ürünler,Cinsel Sağlık,erotik magaza,erotik

  5. Hi…internet is very good world. Because we are learning the information. And than one day fall down internet, we are tobe orphanhood. Thank you very much…

  6. hi there .thanks for plugin:

    Does anybody know if tis script is compatible with WordPress 2.5.1 ?

    Thanks in advance for any help on this!

    best regards


  7. You would think — as bipolars will often go into see the doctor about their depression, but won’t complain about their up mood — and the antidepressant for treating Major Depressive Disorder is likely to trigger a major manic episode — which will be

  8. futbol futbolfutbol futbol futbol futbol futbol futbol futbol futbol futbol futbolresim resim resim resim resim resim resim resim resim resimresim resim web tasarım web tasarım web tasarım web tasarım web tasarım web tasarım web tasarımweb tasarım web tasarım web tasarım web tasarım web tasarım

  9. File Manager doesn't work. I've upgraded CKeditor to 3.1
    Maybe will be changed file manager to any else?
    When will be update for this plugin?
    Thank you for really useful tool.

  10. I am Rhea S. I have visited your website and I would like to congratulate you on building such a valuable online resource. I am sure your visitors find your site as useful as I did.


  11. We are a group of volunteers and starting a new scheme in our community. Your website offered us with valuable info to work on. You have done an impressive job and our entire community will be thankful to you. my website is about white elephant nantucket. would like some feedback if possible

  12. Great goods from you, man. I’ve understand your stuff previous to and you’re just too great. I really like what you’ve acquired here, certainly like what you are saying and the way in which you say it. You make it enjoyable and you still care for to keep it smart. I cant wait to read much more from you. This is really a great web site. my website is about massey shoes. would like some feedback if possible

Leave a Reply

Your email address will not be published.