use query string in URL to display content on the page

I’d like to say something on my page based on what page the person got there from. I can set up the link to that page to be:

www.example.com/page?parameter=myparameter

Is there a way I can access that parameter so that I can have it show on the page, somewhere in my content?

3 s
3

Per the OP’s answer within their question:

With your help and some Googling, I put together a shortcode that returns the value of any url parameter. Here it is:

//THIS IS A CUSTOM SHORTCODE TO DISPLAY A PARAMETER FROM THE URL
function URLParam( $atts ) {  
    extract( shortcode_atts( array(
        'param' => 'param',
    ), $atts ) );
    return $_GET[$param];  
}
add_shortcode('URLParam', 'URLParam'); 

I use the shortcode like this to get the trip_type from my URL:

[URLParam param='trip_type']

Leave a Comment