Using the WP API and Backbone-based JS client, I'm trying to update a post's metadata as follows:

var parentId = 96; // the post id
var metaData = new wp.api.collections.PostMeta('', {parent: parentId});
  .done(function(data) {
    var someKey = data.findWhere({key: 'someKey'});
    someKey.set('value', 'newValue');


Everything works fine until the calling of save(), which throws the following error:

PUT http://example.org/wp-json/wp/v2/posts/undefined/meta/1901 404 (Not Found)

Trying to sync the collection also fails.

Any thoughts? Thanks!


Ok, that was quick.

Pass in the parent id, and it works.

someKey.save({parent: parentId});
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.