Using PHP variable inside do_shortcode() for WordPress

first - sorry about the title, not sure exactly how to name what I need.
Here's what I'd like to do:
1) Get the post ID 2) Get the Custom Field from said post id 3) Display shortcode with the custom field's value
Here's what I have:
<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'id-del-instructor', true);
wp_reset_query();
?>
With this, I am able to get and display the shortcode's value - although I need to store it for later use rather than display it.
Then, I found this to display the shortcode with PHP:
<?php echo do_shortcode("[awsmteam id="XXX"]"); ?>
I have tried combining these two codes but every time it breaks my site.
Basically, where it says XXX, I need the value from the shortcode. It's probably something simple to achieve but I have been looping around and can't get my head around it.
Help? :) Thanks so much!
RESOLVED with this code - thanks @Alon Eitan:
<?php
global $wp_query;
$postid = $wp_query->post->ID;
$meta = get_post_meta($postid, 'id-del-instructor', true);
wp_reset_query();
echo do_shortcode('[awsmteam id="' . $meta . '"]');
?>
Answer
Solution:
If you're doing this inside a page template, you could simply do.
$meta = get_post_meta(get_the_ID(), 'id-del-instructor', true);
echo do_shortcode('[awsmteam id="' . $meta . '"]');
rather than call the global $wp_query and go through those other steps.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: foreach() argument must be of type array|object, null given
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.