首页 WordPress函数大全 register_meta()

register_meta()

2020-05-02 / 2946阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

register_meta( string $object_type, string $meta_key, array $args, string|array $deprecated = null )

注册一个元密钥。

描述

建议为对象类型和对象子类型的特定组合注册元密钥。如果忽略传递对象子类型,则将为整个对象类型注册元密钥,但是如果存在相同对象类型和子类型的同名更具体的元密钥,则可以部分覆盖元密钥。

如果对象类型不支持任何子类型,例如用户或注释,则通常应在不传递子类型的情况下调用此函数。

参数

$object_type

(string)
(Required)
Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table.

$meta_key

(string)
(Required)
Meta key to register.

$args

(array)
(Required)
Data used to describe the meta key when registered.

  • 'object_subtype'
    (string) A subtype; e.g. if the object type is "post", the post type. If left empty, the meta key will be registered>
    (string|array)
    (Optional)
    Deprecated. Use $args instead.

    Default value: null

返回

(bool) True if the meta key was successfully registered in the global array, false if not. Registering a meta key with distinct sanitize and auth callbacks will fire those callbacks, but will not add to the global registry.

大家谈论
    我的见解