Created
December 8, 2016 19:57
-
-
Save infn8/83b800d36c6c95a30c7c8b47ed29e3e5 to your computer and use it in GitHub Desktop.
Remove Paragraph Formating in Wordpress on a per post basis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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