register_meta() is a tiny function, which lets you register a sanitization and authorization callback for post meta, term meta, user meta or comment meta. We’re going to expand the utility of this function to describe the data type of the field. This will be useful for the REST API as well as the Fields API. This discussion has started in #35658, but I’d like to share the latest thoughts for general feedback. Imagine a “movie” custom post type which has a “star-rating” post meta field, which should accept the value 1, 2, 3, 4 and 5. REST API clients like the iOS app would want to know this information, so they can offer appropriate UI for their users. Ditto for the Fields API. Here are some loose thoughts on what that API might look like. Here is a post meta field for “mood” that accepts any string. The value would fit in a single row. There would only be one row per post, as it is not “repeatable.” Repeatable might be a default.
Share This