Well, there is a way to update post meta. You have to add the update_callback
when registering rest field. See the example below:
function rest_api_player_meta() {
register_rest_field('sp_player', 'player_meta', array(
'get_callback' => 'get_player_meta',
'update_callback' => 'update_player_meta',
'schema' => null,
)
);
}
function get_player_meta($object) {
$postId = $object['id'];
return get_post_meta($postId);
}
function update_player_meta($meta, $post) {
$postId = $post->ID;
foreach ($meta as $data) {
update_post_meta($postId, $data['key'], $data['value']);
}
}
add_action('rest_api_init', 'rest_api_player_meta');
The meta is stored under player_meta
property in your JSON object you send when creating a new post.
Related Posts:
- WP REST API – Retrieve content from page
- Passing Meta array in wp-rest api
- Show popular post in another php website via WP REST JSON API
- WP REST API only returning partial list of users
- Get Image URL instead of Attachment Id in Rest API
- WP API returning SQL results as strings, rather than numbers
- WP Rest API v2 filter and display latest post with specific tag
- WordPress Rest API: How do we validate with our custom API key?
- Include custom post meta value in fetched JSON
- How to loop through JSON data in wordpress WP REST API
- Unset data in custom post type WordPress API (wp-json)
- Android authentication
- WordPress JSON API returns normal site page in html. How do I get it to give me JSON?
- WordPress REST API “rest_authentication_errors” doesn’t work external queries?
- Create multiple posts with WP REST API at once
- WP REST API format response
- Hook before posting via JSON REST API
- WP REST API. Configuring JSON routes
- WordPress API “code”:”rest_no_route” with Custom Route
- return content section as json in wp rest api v1
- Remove a field from json in wp rest api v1
- Can comments be used in JSON?
- Grabbing the current viewer count for youtube live streaming
- What is the easiest way to convert an Excel spreadsheet with tabular data to JSON? [closed]
- YAML equivalent of array of objects in JSON
- Best way to save data in Unity game
- Javascript Object push() function
- How to parse Excel (XLS) file in Javascript/HTML5
- How do I make a JSON object with multiple arrays?
- Get post count in wp rest API v2 and get all categories
- Query WP REST API v2 by multiple meta keys
- WP JSON REST API (Ryan McCue) how to query posts with specific meta data with ‘AND’ relation?
- Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)
- How do I create a user using the new JSON api in 4.7?
- How to retrieve wp_ json_encode data from custom WordPress database table
- wordpress wp-json prefix issue
- WP API : date_query parameter
- Get the Category Name instead of ID from WP-API
- ping_status in JSON REST API
- Increase the page size of the WordPress REST API
- Options to get my custom post type metadata via the WordPress API
- Have WordPress generate a JSON of the content
- Why does AWStats show /wp-json* as Viewed URLs
- Output JSON object with woocommerce products
- Display post title from WordPress excluding a string via API
- WP_REMOTE_POST Requests are being blocked by API provider [closed]
- How to order WordPress Rest API data
- WP Rest API – How to convert embedded to json object in Java [closed]
- Pre insert data when adding new custom post fire a json error
- Woocommerce api: create product with images – bad request
- Custom endpoint to get all custom taxonomy terms
- Data storage for JS app using WP REST API
- How to send s2member plugin’s wordpress user data in json format to a url in php [closed]
- Create and Update a Json file
- How to display json_encode via $wpdb
- If I use WordPress REST API V2 and someone makes an app using it. Will my site count the posts views from the APP? And if not, then how?
- How to edit feature image with XML RPC?
- Return scheduled posts with WP REST API
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- How to get a custom entry field label with Gravity Forms?
- Get a remote post ID via API given URL
- Core function to check if a rest namespace exists
- How to change the date and time in REST API for comments?
- Is there a way to download only the Rest API part of WordPress?
- Custom Endpoint API based on attribute gutenberg block
- How to see posts in taxonomy endpoint
- JSON – Create rest api endpoint for Advanced Custom Fields
- Custom WP API endpoint NULL body data
- Uploading a media item with the wp-json API to a specific path
- post values to custom post type which has advanced custom fields
- JSON-LD: creating an AggregateOffer from many shortcode
- How to add a rest field to post tags?
- WordPress restrict access to rest only
- how to use nimble-API and Display data?
- How to display relations via wordpress Rest API
- A special character I am trying to include in a page keeps getting rejected with error “Updating failed. The response is not a valid JSON response.”
- How can I create new CustomPostType record using wp.api.collections?
- DELETE request using WP REST API
- register/login api
- How do i post data to url with fields?
- i am using api add post in wordpress
- WP Rest API in Android studio does not show Images
- 403 error rest_’cookie_invalid_nonce’ on API Request
- How do i POST to WordPress rest API from the same domain?
- CRUD from WordPress to Business Central 365 through OData REST API
- JSON Schema Output Object rather than Array
- REST API get featured image source for custom post type
- I would like to retrive JSON value and display it in wordpress page or widget
- Why does “if statement” has to “die()”, otherwise wont work?
- How to create REST Based JSON API(how to modify the code below)?
- WP API users per page
- how build custom json api controller for all registered users
- Make Custom Fields Public in JSON – API
- WordPress REST API not displaying all information
- how to know that a wordpress plugin support using API?
- Custom Backend data for map to JSON file?
- How to update WordPress Plugins in your own maintance application?
- REST API custom endpoints for metaboxes
- WordPress json – How to use the content rendered from json
- Fatal error in custom end point in WP-JSON