Advertisement
Guest User

custom rest-api endpoint wordpress

a guest
Mar 17th, 2022
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. <?php
  2. /**
  3. * Plugin Name: API Plugin
  4. * Plugin URI: https://www.google.com
  5. * Description: Test
  6. * Version: 1.0
  7. * Author: Test
  8. * Author URI: https://www.google.com
  9. */
  10.  
  11. function trying() {
  12. return "Hi";
  13. }
  14.  
  15. add_action('rest_init_api', function() {
  16. register_rest_route('custom/v1/', 'test', [
  17. 'methods' => 'GET',
  18. 'callback' => 'trying',
  19. ]);
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement