The simplest is to use a Custom Field to paste the code and use a Shortcode to make the display in pure HTML.
The post would look like this :
You can use as many shortcodes as you want, just put a unique name for field name , in my example
cod-1
(an arbitrary name).
Custom Field :
Plugin code :
Always see who says "paste this into the functions.php file of the theme" ,
is wrong, make your own plugin , no problem with 20 lines.
<?php
/**
* Plugin Name: (SOpt) Shortcode para código HTML
* Plugin URI: http://pt.stackoverflow.com/a/86941/201
* Version: 1.0
* Author: brasofilo
*/
add_shortcode( 'codigo', 'shortcode_sopt_83496' );
function shortcode_sopt_83496( $atts )
{
global $post;
// field não definido, não faz nada
if ( !isset( $atts['field'] ) )
return '';
// pega valor do custom field no atributo "field" do shortcode
$code = get_post_meta( $post->ID, $atts['field'], true );
// envelopa o código na tag <pre>, estilizar a classe com CSS
return sprintf(
'<pre class="codigo-front">%s</pre>',
htmlentities( $code, ENT_QUOTES )
);
}
Result :
You can use a plugin like Advanced Custom Fields to interface for the CFs instead of the WP default