Custom endpoint not working
-
Hello,
I’m trying to get a custom endpoint working and it’s taking far too long. I get the 404 when using postman with this code and cannot understand why? Can anyone help?
add_action( 'rest_api_init', function () { register_rest_route( 'ng-wp', '/sidebar/', array( 'methods' => 'GET', 'callback' => 'my_awesome' ) ); }); function my_awesome( $data ) { $posts = get_posts( array( 'author' => $data['id'], ) ); if ( empty( $posts ) ) { return null; } return $posts[0]->post_title; }
When I look through wp-json registered endpoints I see two others I’ve registered! But not the one above. It makes no sense?
https://www.ads-software.com/plugins/rest-api/
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Custom endpoint not working’ is closed to new replies.