You have to create the function and call it when post ID is already set. Otherwise it will be empty. E.g. wp_head
meets this requirement, init
is too early.
function my_selective_wpautop() {
global $post;
if( is_singular() ) {
if( 'page' == $post->post_type ) {
remove_filter( 'the_content', 'wpautop' );
} elseif ( 'post' == $post->post_type ) {
add_filter( 'the_content', 'wpautop' );
}
}
}
add_action( 'wp_head', 'my_selective_wpautop' );