Do you want to display code on your WordPress site? By default, WordPress filters out any raw code added into blog posts, pages, widgets, or comments. In this article, we will show you how to easily display code on your WordPress site.

First you need to install and activate the Syntax Highlighter Evolved plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Settings » Syntax Highlighter to configure the plugin settings.

The default plugin settings should work for most websites. However, you should review all settings and make changes if necessary.

Each option has detailed description to explain what it does. Once you are done, simply click on the save changes button to store your settings.

Syntax Highlighter Evolved uses simple shortcodes to display code. For each programming language you need wrap your code in the shortcode for that language.

For PHP you would wrap your code like this:

echo “Hello World”;

It will appear in your post like this:

1. <?php
2. echo "Hello World";
3. ?>

For CSS you will wrap your code like this:

.entry-title {
font-family:”Open Sans”, arial, sans-serif;

It will appear on your site like this:

  1. .entry-title {
  2. font-family:”Open Sans”, arial, sans-serif;
  3. font-size:16px;
  4. color:#272727;
  5. }

Syntax Highlighter will automatically highlight the code for that particular language. It will also add line numbers and handle tab indent properly. Your users will be able to easily copy and paste code snippets from your WordPress site.

How to Display Code in WordPress Without Using Plugin

Many bloggers do not run a development blog, so they don’t need to add sample code snippets in their posts very often. For rare occasions, you can add code by encoding the code into HTML entities. Like this:

&gt;?php echo “Hello World”; ?&lt;

The problem with converting code into HTML entities is that it is difficult to do manually. You can use online tools like this one, to convert code into HTML entities.

By converting PHP, HTML, JavaScript code into HTML entities, you can paste them into your WordPress posts. For additional styling you can wrap code between <code> and </code> tags.

We hope this article helped you find the best syntax highlighter plugin for WordPress. You may also enjoy our article about 13 plugins and tips to improve WordPress admin area.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.