0

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?

1

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();?>

0

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(); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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