How to Display Code on Your WordPress Site Effortlessly

If one runs a blog and if it is associated with development, in case if the individual wishes to share code snippets on his blog, then displaying these codes in the blog is not a simple task. A raw code that is added into the posts, comments, or widgets is filtered by WordPress for security reasons.  Most often if the user uses a display code on his website then that user is asked about the Syntax Highlighter plugin.


Now let us see how the display code can be added easily on a WordPress Website using Plugin. #

First install and activate the Plugin Syntax Highlighter Evolved.

Once it is activated the following screen appears

After activation, select Settings >>> Syntax Highlighter to configure the plugin settings.

For most websites the basic plugin setting will work fine but one must assess all the setting and make the necessary change if required. Every option descriptions are detailed that explains its functions. Once the required selection is made then to store the setting, simply click on save changes.

To display code, the Syntax Highlighter makes use of simple shortcodes. One needs to wrap the required code in the shortcode for that specific language.

If the language is PHP then you have to wrap the code as shown below

< ?php echo “Hi How Are You”; ?>

It will appear in the post like this:

In case of CSS the code will wrapped as shown below

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

It will appear on the site this way-

Syntax Highlighter will spontaneously highlight the code for the specific language. It will also handle the tab indent correctly and add line numbers. The user can easily copy and paste the code snippets from the WordPress website.

How to Display Code on Your WordPress Site without using Plugin #

Most of the blogger those who do not run a development blog, do not often need to add code snippets in their post. Once in a blue moon if required the blog owner can add code by encoding the required code into HTML entities like the subsequent…

&gt;?php echo " Hi How Are You"; ?&lt;

The issue with converting code into HTML entities is that it is tough to do it manually, but there are many tools that can be used Encode the code into HTML entities.
After converting the PHP, JavaScript code into HTML entities they can be pasted into the WordPress post. If additional styling is required, then wrap the code sandwiched between <code> and </code> tags.

Powered by BetterDocs