<?php add_action( 'rest_api_init', function ( $server ) { $server->register_route( 'foo', '/foo', array( 'methods' => 'GET', 'callback' => function () { return 'baz'; }, ) ); } );