答案 0 :(得分:0)
您可以这样做:
add_action('init', 'init_url_custom_function');
function init_url_custom_function() {
add_rewrite_rule('^YOUR_CUSTOM_URL/?', 'index.php?is_custom_function=yes', 'top');
add_rewrite_tag('%is_custom_function%', '([^&]+)');
}
add_action( 'wp', 'check_url_custom_function' );
function check_url_custom_function() {
global $is_custom_function;
if (isset($is_custom_function) && $is_custom_function == "yes")
custom_function();
}
function custom_function() {
// do something
die();
}
PS:你需要重新生成永久链接