Skip to content

Instantly share code, notes, and snippets.

@infn8
Created December 8, 2016 19:57
Show Gist options
  • Save infn8/83b800d36c6c95a30c7c8b47ed29e3e5 to your computer and use it in GitHub Desktop.
Save infn8/83b800d36c6c95a30c7c8b47ed29e3e5 to your computer and use it in GitHub Desktop.
Remove Paragraph Formating in Wordpress on a per post basis
<?php
// knock out default filter
remove_filter('the_content','wpautop');
// add NEW filter
add_filter('the_content','post_custom_formatting');
function post_custom_formatting($content){
global $post;
// to remove the wpautop add a meta field to the post called 'wpautop' equal to 'false'
$nope = trim(get_post_meta( $post->ID, 'wpautop', true )) === 'false';
if($nope){
return $content;//no autop
}
return wpautop($content);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment