Custom Endpoints not working

You’re using the wrong route. The first two arguments of register_rest_route() ar the namespace, and the route. The URL to a REST API endpoint is: (your domain) + ‘/wp-json/’ + (namespace) + “https://wordpress.stackexchange.com/” + (route) So the full URL to your endpoint is: http://domain.com/wp-json/knpv-get/get-submissions But you’re attempting to view: http://domain.com/wp-json/knpv-get Which won’t return the response … Read more

WordPress REST API parameters are not affecting a response

If results should be ordered by a method other than the default asc or desc, you should also pass the orderby parameter. This gives you the ability to order by title, date, parent, type and many more that can be seen here. For example, a request ordering the results a-z by title would be: http://api-address.com/wp-json/wp/v2/posts/?categories=12&order=asc&orderby=title

Advanced Access Manager: RESTful endpoint to refresh token

At first glance it looks like you need to POST the token as a ‘jwt’ property in a JSON object, the same way you’d POST it to the validate endpoint: curl -X POST \ http://dev.wordpress/wp-json/aam/v1/refresh-jwt \ -H ‘Content-Type: application/json’ \ -H ‘cache-control: no-cache’ \ -d ‘{ “jwt”: “0yJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1NDM4OTExNjQsImV4cCI6MTU0Mzk3NzU2NCwidXNlcklkIjoxfQ.0wGIbcTDH5yWSsdStZFct_-auyOFJqf3NKQasTCs4QU” }’ (based on https://forum.aamplugin.com/d/4-how-to-validate-jwt-token) It doesn’t look … Read more

REST API and filtering by meta value

Add a third parameter in the get_post_meta() function as true, that will return the single value of the current post meta, if you don’t set it it will return an array of the values. What is happening now is that internally the query is trying to compare the meta_value with an array instead of a … Read more

I can’t post comment via REST API

I do not recommend doing this. It’s better if you authenticate your users, but you can make an api endpoint that posts a comment like this: add_action(‘rest_api_init’, function () { register_rest_route( ‘api’, ‘api_post_comment’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘api_post_comment’, ) ); }); function api_post_comment() { wp_insert_comment([ ‘comment_approved’ => 0, ‘comment_author’ => ‘test’, ‘comment_author_email’ => … Read more