[API] Cách tạo Custom API Entry Point WordPress
https://wolfactive.dev/cach-tao-custom-api-entry-point-wordpress/
Cách tạo Custom API Entry Point WordPress
Cách tạo Custom API Entry Point WordPress
Khai báo API với WordPress
add_action('rest_api_init','blogRegisterApiSearch');
function blogRegisterApiSearch(){
register_rest_route('blog-api/v1','/blog/offset=(?P\d+)&category-name=(?P[a-z]+[[:punct:]]+[a-z]+|[a-z]+)',array(
'methods' => WP_REST_SERVER::READABLE,
'callback' => 'blogApiQuery',
'args' => [
'offset',
'category-name'
],
));
}Tạo callback function thực thi
Gọi API ngoài giao diện
Tổng kết
Previous[API] Cách tạo Custom Search API trên WordPressNext[API] Cách tạo Custom Api Endpoint Post Request trên WordPress (ok)
Last updated