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.
To install the plugin, download the zip file and upload via the plugin interface of your WordPress site.
Use the shortcode urlparam with the optional parameter of “default”. For example
[urlparam param="FirstName" default="Friend"/].
- 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.
25 thoughts on “URL Params”
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”;
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" /](
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 )
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?
Fred, please see this page for the GoToWebinar Registration plugin. I just added some additional documentation there for ya! 🙂
Do you have a working example of the plugin?
do you have a java code for this….
thanks in advance..
This post is for WordPress sites. You don’t need java for this. Just a WordPress site.
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. 🙂
Hi, thanks for your work on the plugin.
I am trying to use this code in a post: [urlparam param="myvar" /], and I tried using http://mysite.com/pagename?myvar=test and http://mysite.com/pagename/?myvar=test.
For some reason, nothing’s coming through.
Any ideas, or would you maybe be able to help me get things working?
Thanks a lot!
Sounds like there might be an issue with another plugin you have installed. Try disabling other plugins until you find the culprit! 🙂
Hi Jeremy, I love what this plugin does.
Question: how specifically do I set this up to have it work with a form.
I use infusionsoft. I already setup the link to pass the customer information.
On your examples above it specifies how to set it up as a “hello “john”” for example, but I am not sure how to set it up as to when the client arrives in the site, the form is pre-filled.
Thanks in advance for your response.
I have added the following shortcode to the top of my post:
[urlparam param="cat" /]
[urlparam param="name" /]
But I get a 404 when I try this url:
I know I’m missing something easy here…
Jeremy, i’m using your great plugin on a few sites. I tried recently to deploy to a multisite installation and there seems to be some incompatibility with the Domain Mapping plugin. Are you aware of any other users communicating any difficulties when using URL Params with Multisite?
There shouldn’t be any conflict with Multisite, Joe. It’s most likely another plugin botching up the reading of the params. 🙂
Jeremy can this be used to pass query strings from the url to an outbound link on same page? if not is there another solution?
I’m trying to use urlparam to take the query string coming in a post and pass it to a link in that same post but I can’t quite figure out how to build the href attribute of the tag… the value needs to be the page
– user goes to https://mysite/blog/2015/06/03/test-a/?country=CA&zip=N1T
in this post I need to build the href to send user to another post passing the same query string Test b
I can get the values for the query string fine, but can’t figure out how to build the href…
My ultimate goal is to be able to pass that same parameter/cookie value in a link to another site.
I love this WordPress plugin!
I have a question. When I upload a page to my wordpress site through my external page builder (Leadpages is the one I use) the plugin doesn’t work. How can I solve it? Is there a code I can place in the page in Leadpages?
Thanks, Lucas, and that’s a great question! I believe that when Leadpages publishes to your WordPress site, it’s publishing a wholly packaged self-contained page that doesn’t run through WordPress’ standard parser which processes shortcodes hence shortcodes not working on a Leadpage page even if it’s published to your WordPress site. Check with Leadpages support, though, and let me know what you hear back about how you can use WordPress shortcodes on a Leadpage published page…
I’m trying to get the parameter from the current URL in WordPress.
Just looking at your plugin and noticed it hasn’t been updated for a couple of years.
Just wondering if it’s still going to work for WP 5.7.2 or isn’t is being developed anymore?
Heya, Chris, nothing has changed, and it still works wonderfully. 🙂