roborourke / wp-graphql-meta
wp-graphql 的元数据助手
dev-master
2017-05-20 15:13 UTC
This package is auto-updated.
Last update: 2024-09-20 02:47:18 UTC
README
此插件是出色的 WP GraphQL 的附加组件
它基于 WP GraphQL 和 REST API 构建。您使用 register_meta()
注册的任何元数据都将可用于检索。您可以在 REST API 和 GraphQL 中同时获取数据。
安装
- 请确保首先安装并激活 WP GraphQL。
- 将此仓库上传到您的插件文件夹(或使用 git clone)并激活它。
使用方法
您的主题或其他插件可能使用元数据来添加自定义功能。这些数据或功能对于消耗您 API 的前端或其他应用可能是有益的/必需的。
register_meta( 'post', 'custom-key', array( 'type' => 'string', // number, boolean, integer or a type from WPGraphQL\Types 'description' => 'My custom field', 'single' => true, // Whether to make this require a list or not. 'show_in_rest' => true, // Required to make this field public. ) );
注意:如果您使用 WPGraphQL\Types
实例,内置的 REST API 将忽略该字段。