Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
WordPress Plugin Development

Creating Custom REST API Endpoints

Register custom REST routes for your plugin’s data and actions.

WordPress Plugin Development Series (44/95). Prefer one article? Read the complete WordPress plugin development tutorial.

Short description

Define namespace, route, methods, permission_callback, and args schema.

Custom route

add_action('rest_api_init', function () {
    register_rest_route('acme/v1', '/items', [
        'methods' => 'GET',
        'callback' => 'acme_rest_items',
        'permission_callback' => '__return_true',
    ]);
});

Leave a reply

Your email address will not be published. Required fields are marked *