WordPress的做法是使用query_vars
因此,首先将变量添加到数组中:
//add to query vars
function add_query_vars($vars) {
$new_vars = array(\'custom_method\',\'cm_parameter\');
$vars = $new_vars + $vars;
return $vars;
}
add_filter(\'query_vars\', \'add_query_vars\');
然后,您可以签入vars的插件:
global $wp;
if (array_key_exists(\'custom_method\', $wp->query_vars) && isset($wp->query_vars[\'custom_method\'])){
//do your stuff
}