Last active
January 14, 2016 15:08
-
-
Save alrik11es/3430e81f7615f1a3e6d3 to your computer and use it in GitHub Desktop.
Example wordpress REST route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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