Posting Source Code in WordPress

Just when I was posting source code in my previous post, I realised that my newly installed wordpress does not format the source code nicely. (Read: I’m new to Wordpress!)

Nevertheless, I google out and finally able to post source code in my blog.

Here’s how.

  1. Download Plugin: Go to SyntaxHighlighter Plugin Page and download the plugin
  2. Upload Plugin: Extract all files from the ZIP file, making sure to keep the file/folder structure intact, and then upload it to /wp-content/plugins/.
  3. Activate Plugin: Go to the admin area of your WordPress install and click on the “Plugins” menu. Click on “Activate” for the “SyntaxHighlighter” plugin.

And here’s how to use it

When creating a new post, toggle to HTML view.

If the source code you want to use is in javascript, type…

[“language”]alert(‘hello world’);[/ “language”]

in that view.  Replace the above “language” with the language of your choice. In this case, it is replaced with “javascript” (For full supported language, visit author website.)

And it should display like the below.

alert('hello world');

Related posts

Delete files FAST in Linux

Magento – Get the list of products which customer wanted to be notify when it is back in stock

Common Code Error When Upgrading to PHP 8.1