Posting source code on your posts

source code

WordPress does not allow you to use potentially dangerous code on your blog, there is a way to post source code for viewing.
You can easily post syntax-highlighted code on your blog.

1. Install plugin

2. In your wodpress text editor just wrap your code in these tags:

[  code lang=”js”]
your code here

Code in between the source code tags will automatically be encoded for display, you don’t need to worry about HTML entities or anything.

Setting parameters

lang – The language (or lang) parameter controls how the code is syntax highlighted. The following languages are supported: css, html, java, javascript, perl, php

If the language parameter is not set, it will default to “text” (no syntax highlighting).

autolinks (true/false) — Makes all URLs in your posted code clickable. Defaults to true.

collapse (true/false) — If true, the code box will be collapsed when the page loads, requiring the visitor to click to expand it. Defaults to false.

gutter (true/false) — If false, the line numbering on the left side will be hidden. Defaults to true.

highlight (comma-seperated list of numbers) — You can list the line numbers you want to be highlighted. For example “1,5”.

title (string) — Set a label for your code block. Can be useful when combined with the collapse parameter.

More settings here

Hello there!

I hope you find this post useful!

I'm Mihai, a programmer and online marketing specialist, very passionate about everything that means online marketing, focused on eCommerce.

If you have a collaboration proposal or need helps with your projects feel free to contact me. I will always be glad to help you!

Leave a Reply

Your email address will not be published. Required fields are marked *