0
我是新來使用PHP和WordPress,看到this article添加路由到WordPress,代碼,如:如何獲得請求的URL和請求體在使用時wp_router_generate_routes
add_action('wp_router_generate_routes', 'bl_add_routes', 20);
function bl_add_routes($router) {
$route_args = array(
'path' => '^new-demo-route',
'page_callback' => 'my_callback'
);
$router->add_route('demo-route-id', $route_args);
}
function my_callback() {
return "Congrats! Your demo callback is fully functional. Now make it do something fancy";
}
如果在客戶端,我用curl my-domain/new-demo-route?param_key=param_value -d "{ctn: 'here is body'}"
my_callback
,如何獲得請求的URL和請求體