You need to add your function in the template_redirect
hook. You need to first wait for wordpress to finish loading pages before you can add your hook to remove wpautop
, otherwise your hook will simply get run over. So your funtion will look like this
function pietergoosen_remove_wpautop() {
if ( is_page ( 'services' ) ) {
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
}
}
add_action( 'template_redirect', 'pietergoosen_remove_wpautop' );