After WordPress 4.3, the old method of disabling wpautop no longer works. Has anyone discovered a new method for removing this function?
remove_filter( 'the_content', 'wpautop', 99 );
remove_filter( 'the_excerpt', 'wpautop', 99 );
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI guess you don't use it at all, so why don't you just remove the filter?
remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');
I've tested it a few minutes ago (on WP 4.3) and it works.
p.s. I just saw that you use the same function. Sorry for that. What version are you using? This disables the wpautop on 4.3.
wpautop
is added, it's priority is not specified, which defaults to 10.
Sep 8, 2015 at 13:27
On the javascript side, as a crude measure you could just replace the wp.editor.autop
and wp.editor.removep
with no ops:
add_action( 'admin_print_footer_scripts', function () {
?>
<script type="text/javascript">
jQuery(function ($) {
if (typeof wp === 'object' && typeof wp.editor === 'object') {
wp.editor.autop = function (text) { return text; };
wp.editor.removep = function (text) { return text; };
}
});
</script>
<?php
}, 100 );
However on very limited testing although it seems to keep markup it does put it all on one line in the Text editor, which is pretty ugly...
This works well. It's about the priority of the hook :
add_filter( 'the_content', 'njengah_remove_autop', 0 );
function njengah_remove_autop($content) {
// remove autop
remove_filter( 'the_content', 'wpautop' );
return $content;
}
remove_filter
must specify the same priority when the hook was registered withadd_filter
, which in this case is10
, not99