How to use REST API to send user metadata?

I’m not a WP API expert. It sounds like you want to store more information than the API supports, so you will need to add an endpoint – https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/ If you are doing payment processing, I assume you are using a service or plugin + service for that, so you may want your custom endpoints … Read more

Custom REST API endpoint returns rest_no_route when called via wp-json permalink

The problem is with the bbe_sortables&replace in the permalink: <My URL>/wp-json/bridge/v1/test-data/process/bbe_sortables&replace&_wpnonce=<thenonce> which results in an invalid route, where the supposedly query string is seen as part of the route: /bridge/v1/test-data/process/bbe_sortables&replace&_wpnonce=<thenonce> (the valid route for that URL is /bridge/v1/test-data/process/bbe_sortables) and eventually the REST API throws the rest_no_route error. To fix the problem, use add_query_arg() when generating … Read more

How to add / embed an author into REST data from a custom post type?

I found out how to grab each result and add a link. For the ananda_video_audio post type: add_filter( ‘rest_prepare_ananda_video_audio’, function( $results ) { // These two lines are unique to our code of course $video = new Ananda_Video_Audio( $results->data[‘id’] ); $authors = $video->get_author_IDs(); foreach( $authors as $author_id ) { $results->add_link( ‘author’, rest_url( ‘/wp/v2/users/’ . $author_id … Read more

Using The REST API How To Pull All Custom Posts?

The filter is dynamic, i.e. generated from rest_{$post_type}_query. So for the post post type it’s rest_post_query and for the cpt post type it’s rest_cpt_query Note that REST pagination is available: https://example.com/wp-json/wp/v2/posts?per_page=100&page=1 https://example.com/wp-json/wp/v2/posts?per_page=100&page=2 … The maximum of per_page is to reduce the risk of fatal errors if available resources are exceeded when too many items are … Read more