Removing "wpautop" (auto <p> tags) only on certain pages?

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' );
} ?

Topic wp-autop the-content functions php filters Wordpress

Category Web

About

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