Skip to content

Instantly share code, notes, and snippets.

@enigmaticape
Created December 3, 2012 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enigmaticape/4197551 to your computer and use it in GitHub Desktop.
Save enigmaticape/4197551 to your computer and use it in GitHub Desktop.
Wordpress does bad things with shortcodes and p tags
<?php
// ...
function eschtml_func( $atts, $content = null ) {
return htmlentities( $content );
}
add_shortcode( 'eschtml', 'eschtml_func' );
?>
<?php
// ...
function eschtml_func( $atts, $content = null ) {
return htmlentities( $content );
}
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);
add_shortcode( 'eschtml', 'eschtml_func' );
?>
@enigmaticape
Copy link
Author

From a post about the various ways you can stop wordpress wpautop clobbering the content in your enclosing shortcodes and doing surprising things with P tags at Enigmatic Ape Blog : http://www.enigmaticape.com/blog/wordpress-shortcode-p-tags-an-html-escape-plugin/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment