Last active
November 30, 2017 12:37
-
-
Save pinalj/d40169c9b774cb335d94d2986a6970ee to your computer and use it in GitHub Desktop.
Create custom REST route
This file contains 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 | |
add_action( 'rest_api_init', 'my_register_route' ); | |
function my_register_route() { | |
register_rest_route( 'my-route', 'my-phrase', array( | |
'methods' => 'GET', | |
'callback' => 'custom_phrase', | |
) | |
); | |
} | |
function custom_phrase() { | |
return rest_ensure_response( 'Hello World! This is my first REST API' ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment