- Messages
- 7
- Likes
- 0
- Points
- 1
Alex posted an explanation in the WordPress forum about how to do this. He said:
In the new version of the plugin I made it possible to pass the value through shortcodes. You can get the values of the variables from shortcode attributes. For example, if you set the my_type attribute for the shortcode [wbcr_php_snippet id="2864" my_type="button"], you can get the value of the my_type attribute in the snippet by calling $my_type var.
And here is my question:
Following the explanation above, I created the following snippet:
insertBlurb($imageCode);
where insertBlurb is a function defined in custom.php using the Thesis theme.
When I place the shortcode in a page as follows:
[wbcr_php_snippet id="8931" imageCode="AA"]
the function does not execute properly as expected --- nothing appears on the page.
HOWEVER, if I change the snippet like this:
insertBlurb('AA');
giving the actual value of the variable in the content of the snippet, the function executes properly and places the appropriate text on the page.
What is the problem with the first method? I want to be able to define a single snippet that can accept parameters and pass them on to a PHP function. The second method would require an inordinate number of unmanageable snippets. Any insight you can offer would be much appreciated,
Thank you for your assistance.
Timothy Binkley
In the new version of the plugin I made it possible to pass the value through shortcodes. You can get the values of the variables from shortcode attributes. For example, if you set the my_type attribute for the shortcode [wbcr_php_snippet id="2864" my_type="button"], you can get the value of the my_type attribute in the snippet by calling $my_type var.
And here is my question:
Following the explanation above, I created the following snippet:
insertBlurb($imageCode);
where insertBlurb is a function defined in custom.php using the Thesis theme.
When I place the shortcode in a page as follows:
[wbcr_php_snippet id="8931" imageCode="AA"]
the function does not execute properly as expected --- nothing appears on the page.
HOWEVER, if I change the snippet like this:
insertBlurb('AA');
giving the actual value of the variable in the content of the snippet, the function executes properly and places the appropriate text on the page.
What is the problem with the first method? I want to be able to define a single snippet that can accept parameters and pass them on to a PHP function. The second method would require an inordinate number of unmanageable snippets. Any insight you can offer would be much appreciated,
Thank you for your assistance.
Timothy Binkley