Skip to content

Instantly share code, notes, and snippets.

@maechabin
Last active August 29, 2015 14:15
Show Gist options
  • Save maechabin/20c1ce6a81cc50d1051c to your computer and use it in GitHub Desktop.
Save maechabin/20c1ce6a81cc50d1051c to your computer and use it in GitHub Desktop.
WordPress URLの任意のパラメータから値を取得するショートコード
// 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