Skip to content

Instantly share code, notes, and snippets.

@davidjgoss
Created July 5, 2014 10:23
Show Gist options
  • Save davidjgoss/975d6036262c2d00bdc9 to your computer and use it in GitHub Desktop.
Save davidjgoss/975d6036262c2d00bdc9 to your computer and use it in GitHub Desktop.
Stop WordPress filters from touching page HTML
<?php remove_filter( "the_content", "wpautop" );
remove_filter( "the_content", "wptexturize" ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php add_filter( "the_content", "wpautop" );
add_filter( "the_content", "wptexturize" ); ?>
@davidjgoss
Copy link
Author

WordPress' built-in filters will automatically insert <p> tags and convert quotes, amongst other things, on a page's content. This plays well with what the rich text editor does, but if you write your page's content in HTML and want it to be output exactly as you wrote it, it's a problem.

Use this in the custom template for your page where you want the content to appear. It just turns off the filters whilst your content is output, then turns them back on again.

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