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 want the remove wpautop filter working only on posts from my blog. Because at some pages i need the autop, and at some pages i need it to not be there.

I use the following rule and it is in my theme's functions.php:

remove_filter( 'the_content', 'wpautop' );

Because I only want it on blogposts I was thinking about an if statement, I searched the conditional tags page in Wordpress and found out I can use is_single .

But it doesn't work.

This is the code I use now.

if(is_single() ){
     remove_filter( 'the_content', 'wpautop' );
}

It is still wraped by an p.

And even if it would have worked, there is an other problem. That is that is_single effects ALL singles from post types. And I only want the single of a blog post(posts).

Anyone know how to fix it?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Generally it's not a common way to strip wpautop with remove_filter as it is native functionality of WordPress.

But if you want to : place the remove_filter() function right before the the_content() function on the pages/templates where you don't need the wpautop

<?php remove_filter( 'the_content', 'wpautop' ); the_content();?>

share|improve this answer
    
thank you, what worked :) –  Maartje Jul 25 '13 at 13:53
add comment

I found it.

Really simple.

I just added the remove filter rule at the top of my document, above the header. So now i have

<?php remove_filter( 'the_content', 'wpautop' ); ?>
<?php get_header(); ?>
share|improve this answer
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.