2017-06-14 95 views

回答

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:你需要重新生成您的永久鏈接

+0

完美,這就是我正在尋找..謝謝: –