How to make this shortcode work for post content wordpress [duplicate]

This will not work in the post content context because filter for wpauto is executed before the shortcodes are processed. So, your shortcode tries to disable wpauto filter, but that filter was already executed on that content.

You can do with this (in theme functions.php file, and similar for excerpt):

add_action('the_content', 'wse_281097_content_remove_wpautop', 1);
function wse_281097_content_remove_wpautop() {
    if (is_single(15)) {
        remove_filter('the_content', 'wpautop');
    }
}

This will remove wpauto early by checking if the current post is with ID 15, so it will disable wpauto for that post only. You can replace condition in line 3 with anything you want to target your specific posts.