URL Parameter WordPress Shortcode Plugin

The other day I was setting up a form on the consulting page with Gravity Forms. If you haven’t used Gravity Forms yet, you really should. It has this really cool feature where when the user finishes filing out a form they can be redirected to a URL of your choice. This URL can then contain a query string that can be used to capture data or personalize a thank you message. I love that idea because it makes form confirmation so much more friendly. Take a look at my thank you page as an example. However WordPress does not include an easy method of capturing these query values to display in content.

So I knew it was time to create a plugin! The full source code is found below. Heres how it works:

Lets say that you have a URL like so: http://joehall.me/thank/?fname=John and you want to print the value for “fname” in the text of the page. Then all you need to do is install the plugin below and use the following shortcode where ever you’d like to print that value.






Full Source:

 * Plugin Name: URL Parameter Shortcode Plugin
 * Plugin URI: http://joehall.me/url-parameter-wordpress-shortcode-plugin/21/
 * Description: A shortcode to display the value of a parameter in a URL query string.
 * Version: 1
 * Author: Joe Hall
 * Author URI: http://joehall.me/
 * License: GPL2

function parameters_func( $atts ) {
 $a = shortcode_atts( array(
 'parameter' => '',
 ), $atts );
$q = $a['q'];
return $_GET[$q];
add_shortcode( 'parameters', 'parameters_func' );


  1. That’s pretty clean. Nice work.

  2. Is the parameter value cookied so that it appears on any page on the site as the user browses or leaves and comes back?

  3. Hi John !

    Your solution sounds interesting 🙂
    I have to solve a case, where a URL parameter (ZIP code) is handled by three websites:

    Website A (not WordPress) has a form, where the ZIP code can be entered by the user.
    After entering the ZIP code, Website 2 (a page in my wordpress installation is opened in a new tab with the ZIP code as a parameter in the URL).
    On my page you can press “order” and open Website 3 (not wordpress).
    In the link of website 3 the ZIP code parameter has to be part of the URL so it can be parsed by website 3.

    So my WordPress has to “grab” this URL parameter of website 1 and after pressing a button open website 3 with the parameter still added to the URL.

    Do you have any idea how this can be done ?
    Kind regards

Leave a Reply to keith Cancel reply