register_rest_field()
register_rest_field( string|array $object_type, string $attribute, array $args = array() )
在现有的WordPress对象类型上注册新字段。
Registers a new field on an existing WordPress object type.
返回(Return)
无返回值
源码(Source)
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
4.7.0 | wp-includes/rest-api.php:116 | 1 function | 1 function |
笔记(Notes)
将所有post meta添加到post meta字段的示例:
获取回调最多接受4个参数…
此代码在WordPress4.9.4中有效(也适用于附带的主干客户端):
register_rest_field() 为WP2原创文章,链接:https://www.wp2.cn/functions/register_rest_field/