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.
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
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.
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…
>?php echo " Hi How Are You"; ?<
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.
Powered by BetterDocs
Your email address will not be published. Required fields are marked *
Save my name, email, and website in this browser for the next time I comment.