Plugin: Syntax Highlight.

By John Leschinski | WordPress Plugins

Apr 26

If you’ve ever tried to include a snippet of code in your post you might have run into a common problem where WordPress decides to work it’s magic and format your code into something pretty unusable for demonstration purposes. You might have tried to code tag, but that doesn’t help much either.

One solution is to run your post through a tool to convert the code into something WordPress won’t modify. This is what I used in my last post. But a better solution is a plugin called Syntax Highlighter that saves you the extra steps and formats everything much more nicely.

All you do is wrap your code in [ sourcecode language=’ Appropriate language here ‘] and voila. So the following,

[ sourcecode language='php']

<?php if ( is_category(5) ) { ?>

<a href="/News/"><div class="menu_active">News</div></a>

<?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=5&title_li='); ?>

<a href="/opinion/"><div class="menu_inactive">Opinion</div></a>
<a href="/archives/"><div class="menu_inactive">Archive</div></a>

Will displays like this.

[sourcecode language=’php’]< ?php if ( is_category(5) ) { ?>

< ?php wp_list_categories(’orderby=id&show_count=1&use_desc_for_title=0&child_of=5&title_li=’); ?>


Now isn’t this much nicer? Kevin just installed this plugin here at Blogging Tips and hopefully it will make it easier and prettier for posts with code from here on.

About the Author

John Leschinski is the creative director and founder of Leschinski Design. John's skill and talent is sought after by large and small companies and organizations, both local to the Rainy River district, London Ontario, and globaly. His experience and knowledge are also used in classrooms to groom the next generation of web developers and business seminars discussing e-commerce and the value of good design.

Comments are closed