I am trying to pass a variable value to a shortcode attribute. I can't get it to work.
Is the following supposed to work, or must values be literal?
$mycat = 'books'; $myshortcode = '[products category="'.$mycat .'"]'; echo do_shortcode($myshortcode);
The above outputs nothing. If I replace it with
$myshortcode = '[products category="books"]'; echo do_shortcode($myshortcode);
Then it produces the expected result.
I'm placing this code in a 'Custom Code Block' in the HeadWay Theme's Visual editor. I'm trying to find out if the problem I have has to do with the way HeadWay parses the content of the custom code block, or if it is indeed not possible to construct a string for use with
do_shortcode() like this.