The URL Params WordPress Plugin allows you to access URL parameters in the Query String of the URL.
The plugin even allows you to specify a default value in the shortcode if the parameter isn’t set, so if you want to say “Hello, FirstName” and FirstName isn’t set, it could say something like “Hello, Friend!”
To specify a backup url paramater, enter multiple paramaters seperated by commas. The plugin will check for each paramter, in order, until a matching one is found and return that. Failing finding any of the paramaters you listed, the default will be returned. For example, you can specify [urlparam param="FirstName, First, name" default="Friend" /] to check for FirstName, and if not found, then First, if not found, then name, and if not, then just return “Friend”.
This is great if you have personalized links, like from Infusionsoft, as it lets you personalize a landing page with a persons name.
You can also use this to pre-fill out form fields for folks based on the querystring. For example, if their first name is passed in the URL, your landing page can greet the viewer by name and pre-fill their name on a form.
Installation:
To install the plugin, download the zip file and upload via the plugin interface of your WordPress site.
Usage:
Use the shortcode urlparam with the optional parameter of “default”. For example or [urlparam param="FirstName" default="Friend"/].
Updates:
- 0.3: Released 6/25/2011. Added support for alternative paramters, i.e. param=”FirstName, First, name”
I’m always open to suggestions and ideas on how to improve this plugin. Please make suggestions by commenting below.
Pingback: Integrating Infusionsoft Links with Wordpress | Jeremy B. Shapiro's Blog
Hi Jeremy,
I’m trying to pass parameters via URL for the purpose of showing a different tracking phone number depending on the URL parameter passed, and in my efforts I found your plugin. The problem is that once the user clicks to a different page, the parameter is no longer there. The solution I think is to use some global variable or session data, but my PHP skills aren’t that great so I’m just trying to hack it all together. Is there a way to store a url parameter to a session variable and the call that data later after the user has clicked to a different page?
Not to dilute from your plugin, obviously if there is way to do this with it that would be great, but my approach prior to finding your plugin was to use this code:
(wordpress will probably filter some of this syntax)
$val = $_GET['trackingphonenumber'];
if(empty($val)) echo “Call us at 555-1212″;
else
echo “Call us at $val”;
But I’m not storing that data to a session or calling it back.
Any suggestions as to how I can mod your Plugin or my own code to make this work between pages?
Great question! For starters, to do what your code does, you’d just use this:
Call us at [urlparam param="trackingphonenumber" default="555-1212" /](To keep it between sessions and not get too complicated with plugins or PHP, just use Javascript. Have the JS check for the paramater. If it’s there, set a cookie. On subsequent page loads, have it check, if the cookie is set, have it modify the spot for the phone number on the page.
Are you looking to embed this phone number in your site’s theme, i.e. on all pages? In that case, you can just hard code it with PHP in your child theme using PHP Sessions. (more info at http://www.php.net/manual/en/book.session.php )
GoToWebinar Registration
Thank you for creating this. I’m not sure how else to contact you, but is it possible to get more information about how to implement the plugin?
Thanks
Fred
Fred, please see this page for the GoToWebinar Registration plugin. I just added some additional documentation there for ya!
Awesome thanks!
Hi Jeremy,
Do you have a working example of the plugin?
Great post…
do you have a java code for this….
pls help…
thanks in advance..
This post is for WordPress sites. You don’t need java for this. Just a WordPress site.
Dear Jeremy!
I have some problems using your plugin tag within another tags.
I.e. standalone [urlparam param="email" /] is working but if I’m including [urlparam param="email" /] into Shortcode Exec PHP tags like [subscribe][urlparam param="email" /][/subscribe] – the page generated contains a tag but not its value. So the “subscribe” script will receive [urlparam param="email" /] but not its value
In order for a shortcode to be inside of another shortcode, the outside shortcode needs to run do_shortcode() on the return value. Most shortcodes don’t do this so that won’t work. If you want, go edit the code for your subscribe tag and set it up to return do_shortcode() on the return value.