Created
October 19, 2017 14:34
-
-
Save rob-gordon/32510faf33e2f7ac286fe4ab0a4a6602 to your computer and use it in GitHub Desktop.
Quick custom wp 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
| /* Rest Routes */ | |
| function theme_data() { | |
| $obj = []; | |
| $obj["site_url"] = get_site_url(); | |
| return $obj; | |
| } | |
| add_action( 'rest_api_init', function () { | |
| register_rest_route( 'theme', 'data', array( | |
| 'methods' => 'GET', | |
| 'callback' => 'theme_data', | |
| ) ); | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment