Stop WordPress from auto-formatting certain codes
I have a small question for you. How can I stop Wor开发者_运维百科dPress from changing the &
symbol to &
? I found the solution to stop formatiing the code with pharagraphs by remove_filter('the_content', 'wpautop'); but for this one I can't find it anywhere. Thank you!
Typically, I do most of my editing in the "HTML" tab view. Then I know the characters I enter will not be altered.
But there are times I want characters to be HTML-encoded. For example, I might mention some computer code in a post. I want the users to see those special characters, instead of the page interpreting my code example as HTML to be rendered. Then I go to the "Visual" tab to enter them.
In this way I have quick access to enter literal characters or to have them HTML-encoded.
If you really do want to prevent WordPress from ever encoding those characters, try some of these plugins. I haven't tried them, but they may help. http://wordpress.org/extend/plugins/raw-html/ http://wordpress.org/extend/plugins/preserve-code-formatting/
This caused me great headaches, so I created a shortcode to stop this behavior:
function do_not_filter_content_shortcode( $atts, $content ) {
return wp_specialchars_decode($content);
}
add_shortcode( 'do_not_filter', 'do_not_filter_content_shortcode' );
精彩评论