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.
This is an issue of single quotes vs double quotes,
see What is the difference between single-quoted and double-quoted strings in PHP?
this fix should work:
echo do_shortcode("[product id=\"$itemid\"]")