1

I'm using the remove_filter in functions.php to remove the auto insertion of <p> and <br> tags on my wordpress site.

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

But one of our pages (wiki) is being dynamically created and to make a long story short, it relies on the <p> tags.

How and where should I write an if statement that targets only certain pages to apply the remove_filter to?

I've tried placing this code in the both the functions.php, front-page.php, and page.php files but nothing seems to work.

<?php if ( !is_page( 'wiki') ) { 
  remove_filter( 'the_content', 'wpautop' );
  remove_filter( 'the_excerpt', 'wpautop' );
} ?>
  • Did you put the code in a function called via wp or a later hook? Because you should, for is_page() to give you the proper results. – Sally CJ Feb 14 at 0:24
  • you can also write your own content filtering function and use that on get_post_field('post_content') with more or less the same result. the_content filter runs about 5 filters including wpautop. Run just 4 of them. There are potential solutions this is just one. – Joel M Feb 16 at 15:31

Your Answer

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

Browse other questions tagged or ask your own question.