register_post_meta() WordPress Function
The register_post_meta() function is used to add meta data to a post. This function takes two arguments: the post ID and the meta key. The post ID is used to identify the post to which the meta data will be added. The meta key is used to identify the meta data.
register_post_meta( string $post_type, string $meta_key, array $args ) #
Registers a meta key for posts.
Parameters
- $post_type
(string)(Required)Post type to register a meta key for. Pass an empty string to register the meta key across all existing post types.
- $meta_key
(string)(Required)The meta key to register.
- $args
(array)(Required)Data used to describe the meta key when registered. See register_meta() for a list of supported arguments.
Return
(bool) True if the meta key was successfully registered, false if not.
Source
File: wp-includes/post.php
function register_post_meta( $post_type, $meta_key, array $args ) { $args['object_subtype'] = $post_type; return register_meta( 'post', $meta_key, $args ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.9.8 | Introduced. |