Last active
August 29, 2015 14:15
-
-
Save maechabin/20c1ce6a81cc50d1051c to your computer and use it in GitHub Desktop.
WordPress URLの任意のパラメータから値を取得するショートコード
This file contains 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
// URLの任意のパラメータから値を取得 | |
function get_param_val($atts) { | |
extract(shortcode_atts(array( | |
"name" => "" | |
), $atts)); | |
$val = (isset($_GET[$name]) && $_GET[$name] != "") ? $_GET[$name] : ""; | |
$val = htmlspecialchars($val, ENT_QUOTES); | |
return $val; | |
} | |
add_shortcode("param", "get_param_val"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment