TIP: Using variables in a Shortcode
Posted: January 13th, 2011, 4:17 am
It is possible to configure Shortcode Attributes dynamically.
But first, you will need to install a PHP Execution plugin.
http://wordpress.org/extend/plugins/php ... on-plugin/
Now, let's assume you have a URL like this on your site:
Inside your Membership Options Page, or whatever Page contains your Shortcode, you can do this:
So in this example, the "ra" attribute ( i.e. the Regular Amount ), is configured dynamically based on the value of ?amount=129.00 in the URL. This particular example may or may not be useful to you, but it demonstrates your ability to configure Shortcode Attributes dynamically. You could even take this a step further by constructing custom forms on your site that contain options; which ultimately dictate the amount that you'll charge. Where the final amount is configured dynamically.
* NOTE: You MUST be in the HTML tab of your editor when adding PHP tags.
But first, you will need to install a PHP Execution plugin.
http://wordpress.org/extend/plugins/php ... on-plugin/
Now, let's assume you have a URL like this on your site:
- Code: Select all
http://www.YOURSITE.com/membership-options-page/?amount=129.00
Inside your Membership Options Page, or whatever Page contains your Shortcode, you can do this:
- Code: Select all
[s2Member-PayPal-Button ... ra="<?php echo esc_attr($_REQUEST["amount"]); ?>" ... /]
So in this example, the "ra" attribute ( i.e. the Regular Amount ), is configured dynamically based on the value of ?amount=129.00 in the URL. This particular example may or may not be useful to you, but it demonstrates your ability to configure Shortcode Attributes dynamically. You could even take this a step further by constructing custom forms on your site that contain options; which ultimately dictate the amount that you'll charge. Where the final amount is configured dynamically.
* NOTE: You MUST be in the HTML tab of your editor when adding PHP tags.