Skip to content

Instantly share code, notes, and snippets.

@alrik11es
Last active January 14, 2016 15:08
Show Gist options
  • Save alrik11es/3430e81f7615f1a3e6d3 to your computer and use it in GitHub Desktop.
Save alrik11es/3430e81f7615f1a3e6d3 to your computer and use it in GitHub Desktop.
Example wordpress REST route
<?php
// http://my-site.com/wp-json/pandora/avatar
function my_func()
{
register_rest_route( 'pandora', '/avatar', array(
'methods' => \WP_REST_Server::READABLE,
'callback' => 'my_call',
)
);
}
function my_call()
{
$class = new stdClass();
$class->test = 'This is what is going to be out';
return $class;
}
add_action( 'rest_api_init', 'my_func', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment