Use WP Syntax Plugin To Highlight Code in WordPress

If you are developer who loves to share different code snippets with world, WordPress provides the perfect platform to do so.

There are many plugins available in WordPress to highlight your code in wordpress posts. My personal favorite is WP-Syntax plugin. You can easily add code snippets of various languages be it Ruby, PHP, Java, XML, SQL to name a few with this plugin.

Installation & Activation
Using this plugin is quite easy. You can install the plugin by searching for WP-Syntax plugin under the Plugins>Add New>and search for “WP-Syntax”.

Using Plugin
To use the code in WordPress post, you just need to wrap the code with pre tag.

  • Use the “line” attribute of plugin to further enhance the code and add line numbers to your code.
  • “lang” attribute helps you specify language of code that you are writing
  • “highlight” attribute lets you highlight specific line of your code

So if you are looking to share your code with world, just install WordPress and WP-Syntax plugin.

To see the plugin in action, look at the code below

1
2
3
4
5
6
7
<div id="foo">
<?php
  function foo() {
    echo "Hello World!\n";
  }
?>
</div>