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 );
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 );
Share
Improve this question
edited Sep 2, 2015 at 15:32
Robert hue
8,5662 gold badges34 silver badges50 bronze badges
asked Sep 2, 2015 at 15:30
C4talystC4talyst
791 silver badge2 bronze badges
3
|
3 Answers
Reset to default 7I 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.
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
– shea Commented Sep 9, 2015 at 1:52