Closed sinmax01 closed 6 years ago
I think it's reasonable to expect a missing featured_media
id not to be replaced by a 0. Would you care to submit this as a PR?
I did not get to reply to this issue, but now I found that polushinmk solved it. Thanks!
If I create a new Post object, set the field values I want to be updated (but not the FeaturedMedia field) and then call the Update method, the featured_media in JSON is set to 0, so the previous Featured Media of the post is deleted. As a work-around, I created a new class, MyPost that inherited Post, and override the property FeaturedMedia: [JsonProperty("featured_media", NullValueHandling = NullValueHandling.Ignore)] public new int? FeaturedMedia { get; set; } This way, as the FeaturedMedia is not sent to the REST API, it is not replaced in WordPress, but the old value before the update request is kept. I think this property should replace the FeaturedMedia property in the Post class. And if there are other cases like this one, I think they should also be replaced.