Last active
April 11, 2018 12:16
-
-
Save vanbernaert/28d44b4781d12e5314091e2b970f502f to your computer and use it in GitHub Desktop.
WordPress Shortcode function to use URL QueryString value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function URLPARAM( $att01 ) { | |
extract( shortcode_atts( array( | |
'var' => 'var', | |
), $att01 ) ); | |
if (isset($_GET[$var])) { | |
return $_GET[$var]; | |
} | |
} | |
add_shortcode('URLPARAM', 'URLPARAM'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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