Remove_filter ('the_content', 'wpautop') is not working

I've tried disabling WP's auto-paragraph thingy using

remove_filter ('the_content', 'wpautop');

but I am still getting my stuff wrapped in automatic p tags... What am I doing wrong?

Its at the bottom of a functions file. Its not in functions.php, but in a file that functions.php includes (and putting it in functions.php doesn't change the behaviour at all).

Update: var_dump( $wp_filter['the_content'] ); outputs NULL. How can I test why this filter isn't being run?

Topic functions wysiwyg Wordpress

Category Web


My problem was while developing a shortcode. Credits to Samuel Wood. See his advice here:

Oh, and if you’re putting in shortcodes, use a shortcode block instead of typing them into a P block. Then you won’t have wrapper P tags.

https://wordpress.org/support/topic/wpautop-not-working-on-wp_editor/


Had same problem, fixed with css:

<style>
p:empty{
  height: 0;
  margin: 0;
  padding: 0;
}
</style>

If you're using the TinyMCE Advanced plugin, try unchecking this advanced option:

Stop removing the <p> and <br /> tags when saving and show them in the HTML editor

Unchecking that and using the remove_filter ('the_content', 'wpautop'); code in my functions.php did the trick for me.


Your code is absolutely correct. You can try this snippet in template to ensure it is being removed:

var_dump( $wp_filter['the_content'] );

If it's not it may be that code never reaches your filter removal (return above it for example) or filter is re-added later by some other code.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.