Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
non-namespaced route for WP REST API
<?php
add_action( 'rest_api_init', function ( $server ) {
$server->register_route( 'foo', '/foo', array(
'methods' => 'GET',
'callback' => function () {
return 'baz';
},
) );
} );
@mustafauysal

This comment has been minimized.

Copy link
Owner Author

@mustafauysal mustafauysal commented Jun 22, 2017

alternatively

 rest_get_server()->register_route( 'foo', '/foo', array(
        'methods'  => 'GET',
        'callback' => function () {
            return 'baz';
        },
    ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment