Skip to content

Instantly share code, notes, and snippets.

@vanbernaert
Last active April 11, 2018 12:16
Show Gist options
  • Save vanbernaert/28d44b4781d12e5314091e2b970f502f to your computer and use it in GitHub Desktop.
Save vanbernaert/28d44b4781d12e5314091e2b970f502f to your computer and use it in GitHub Desktop.
WordPress Shortcode function to use URL QueryString value
function URLPARAM( $att01 ) {
extract( shortcode_atts( array(
'var' => 'var',
), $att01 ) );
if (isset($_GET[$var])) {
return $_GET[$var];
}
}
add_shortcode('URLPARAM', 'URLPARAM');
@vanbernaert
Copy link
Author

put this function in your WordPress Theme file: functions.php

URL example: www.mywebsite.com/?myname=Kristof
1/ Use shortcode in page/post/widget: [URLPARAM var="myname"]
2/ The value you will get is: Kristof

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment