Writing code in a WP post is not a good idea. As czerspalace mentions the easiest solution is to use a Custom Field to paste the code and use a Shortcode to render it in HTML.
The post would be like:
Any number of shortcodes can be used, just put a unique name for each field name,
in this example cod-1
(an arbitrary name).
The Custom Field:
Plugin code:
See Where do I put the code snippets I found here or somewhere else on the web?
<?php
/**
* Plugin Name: (SOpt) Shortcode para código HTML
* Plugin URI: https://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 not defined, do nothing
if ( !isset( $atts['field'] ) )
return '';
// get custom field attribute value from Shortcode's "field"
$code = get_post_meta( $post->ID, $atts['field'], true );
// envelops code in <pre> tag, stilize at will with CSS
return sprintf(
'<pre class="codigo-front">%s</pre>',
htmlentities( $code, ENT_QUOTES )
);
}
Result:
Any Custom Fields plugin can be used to make a nice interface, instead of WP default.
Originally posted at Stack Overflow em Português