You don’t need to modify the global current post, just use the get_posts() function instead of WP_Query().
function get_root_project_value( $meta_key ) {
if ( empty( $meta_key ) ){
return false;
}
$args = array(
'post_type' => 'slug',
'meta_query' => array(
array(
'key' => 'project_is_root_project',
'value' => '1',
),
),
'posts_per_page' => 1, // If you want only one result, set to 1 instead of -1
'fields' => 'ids', // To get only ids. No need more
);
$project_ids = get_posts( $args );
if ( !empty($project_ids) ){
foreach ( $project_ids as $project_id ) {
return get_field( $meta_key, $project_id );
}
}
return false;
}