Ever since we started this site I have been struggling with posting code snippets into WordPress blog posts. First I was attempting to use the <pre> and <code> tags but they would blow out the side of my Mandingo theme with two columns. I would then try to go through the code and break the lines at the right places trying to do the formatting myself… no a brilliant idea. Justin whom also posts on this site suggested Markdown which works great. I even put some effort into learning it and don’t mind using it at all. I installed the Text Control plugin and replaced its markdown.php with Markdown Extras markdown.php file which worked like a charm. My problem was that I was still blowing out the side of my theme. After a fairly long search I found a plugin that I did not find on WordPress.org but directly on the developers site called QuickCode which you can locate here.
I knew QuickCode was going to work for me after Chrissy stated how annoying it is when WordPress strips out tags using carrots that it doesn’t understand. So with QuickCode you can use brackets instead of the carrots and the QuickCode statements are visible in the Visual or HTML tabs when writing posts.
Here is a brief example:
You can also add different titles to QuickCode snippets such as:
I made some modifications to the quickcode.css file as well. The primary one was changing width from 99% to 486px to work with my theme. If I did not do this it was still blowing out the side of every page. The other small modifications I made included changing the overflow CSS tag behavior, adding a border, and changing the colors around. The only file I had to touch was the quickcode.css file to get QuickCode to work perfectly for me.
For more information visit the NetNerd’s site. Thanks to her it will no longer be such a struggle for me to post code. :)