PHP using a variable inside do_shortcode() – WordPress Page Template

The format for the shortcode that I wish to do is: [product id=”id#”]
The format for do_shortcode is: do_shortcode(‘[shortcode’);

My question is how can I insert a PHP variable as the id#?

I have a variable $itemid that I would like to use like this:

echo do_shortcode('[product id="$itemid"])

But I cannot for the life of me get it to work. Any suggestions would be greatly appreciated.

Source: shortcode

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.