Displaying Code Snippets in WordPress

Well, not technically a programming issue, but I want the plugin for my WordPress blog to display code snippets.

Can anyone here recommend a good one? Also, you guys know which Jeff is using for coding. It looks very good.

Thanks.

+4
source share
3 answers
+3
source

I think you might be interested in run-this - there is a wordpress plugin that allows your readers to run your snippets in a browser.

+2
source

For WP snippets, I use Prettify .

You should probably use a character escaping plugin to be able to display the code without having to do it yourself, or your code will not be displayed. Or just put this in functions.php in the theme folder to do this automatically:

function bbcode( $attr, $content = null ) { $content = clean_pre($content); // Clean pre-tags return '<pre"><code>' . str_replace('<', '&lt;', $content) . // Escape < chars '</code></pre>'; } add_shortcode('code', 'bbcode'); 

And then wrap your code with [code]<?php echo 'hello world!'; ?>[/code] [code]<?php echo 'hello world!'; ?>[/code]

Source: Code in Messages

+2
source

All Articles