Thread Starter
estr
(@estr)
Tried to put “<?php if (is_single()) { ?>” into [php snippet=1].
And “<?php } ?>” into [php snippet=2].
And then to do the following in the post:
[php snippet=1]
<p>Random text that will be different for each post.</p>
[php snippet=2]
But this does not work 🙁
Thread Starter
estr
(@estr)
In the plugin description it is said that:
“The plugin also contains a variable array which you can add variables to for use between snippets called $_var and is available though the global variable $PHPPC which is an object, so its $PHPPC->_vars[]”
But I am not that advanced to understand how to use this or if this could be used to solve my problem at all.
Plugin Author
Jamie
(@themissingcode)
Hi Estr,
as of version 1.1.1 you can now specify parameters to the plugin’s shortcode using the parameter “param”.
you can specify the value of param in a name=value pair separated by &s.
For example [php snippet=2 param="myvar=myval&othervar=otherval"]
.
There parameters can be accessed within your snippet using $_parameters
variable.
for example: echo $_parameters["myvar"];
would output “myval”
I hope this solves your issue.
Thanks,
TMC
I have a similar question, but I need to insert a [shortcode] that calls a db field as my parameter/variable…
I’m not super great at php, so I may not be defining the parameters/variables within the php correctly…
In the snippet I have…
<?php
echo shortenURL(‘http://aq155.nuteam.com/go/Opp/$_myvar’);
?>
then when I use the short code, I need the myvar = [iw_db_AffiliateID]
something like:
[php snippet=1 param=”myvar=[iw_db_db_AffiliateID]”
So, 2 questions…
1. how do I define “myvar” within the snippet to be a parameter/variable
2. Can I Use a shortcode/db field as the variable, and if so, how do I specify it in there?
Any help would be greatly appreciated by this newbie..
Thanks.
nevermind…figured it out. thanks.