Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

4 Answers

up vote 0 down vote accepted

http://wordpress.org/extend/plugins/noautop/

I made this a while back, you can just install it and use it, or dig into the code (its a super small plugin) and see how I do it. The plugin adds the tag the_content_noautop(); which you can use in your template specifically when you don't need a paragraph tag.

share|improve this answer
add comment

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.

share|improve this answer
2  
or try changing the filter priority, default is 10 –  onetrickpony Jan 12 '11 at 14:08
    
@Ambitious Amoeba not sure what you mean? Priority should match exactly for remove_filter() to work. –  Rarst Jan 12 '11 at 14:17
    
yeah, but if you add a filter with priority 20, shouldn't you remove it with the same priority? maybe autop is added with a different priority... –  onetrickpony Jan 12 '11 at 14:36
    
@Ambitious Amoeba I've checked the source and tested code, it is added without priority specified so default it is. –  Rarst Jan 12 '11 at 14:43
    
var_dump( $wp_filter['the_content'] ); outputs NULL. I've tried grepping for wpautop but apparently none of the php files in wp-content contain this, apart from my line of code. –  Amanda Jan 12 '11 at 19:13
show 8 more comments

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.

share|improve this answer
add comment

Use this Plugin here: http://www.bake-the-web.de/2012/03/22/no-wpautop/

In the plugin-options you can decide where you want to disable wpautop. In the Excerpt, the Content or both.

share|improve this answer
    
Except I shouldn't need a plugin when this code should just work. I don't want to add extra overhead where unnecessary. –  Amanda Mar 27 '12 at 11:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.