WP Query/Noindex

I have deactivated a few things on my WP site with this:

    add_action('template_redirect', 'remove_wp_archives');
        function remove_wp_archives(){
             if( is_tag() || is_attachment() || is_author() || is_date() ||  is_search()) {
                global $wp_query;
                $wp_query->set_404();
             }
    }

Does this mean that I would still need to add noindex to these pages/archives if I don’t want them to get indexed? Or will the search engines be redirected to 404 and since I have set noindex to that, it will automatically be noindexed?

Related posts