First we need to add the following code to our functions.php.

add_action('rest_api_init', function () {
    register_rest_route('namespace', '/path', [
        'methods' => 'GET',
        'callback' => function () {
            return $_GET;

Then we can create a simple form and process the request via Javascript.

$('form').on('submit', function (e) {

        type: 'GET',
        url: '/wp-json/namespace/path',
        data: $('form').serialize()
    }).done(function (response) {

Alternatively, you can also call the following URL directly in the browser:

Leave a Reply

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