Wordpress - What is "meta_input" parameter in wp_insert_post() used for?
This part of wp_insert_posts()
gives it away:
if ( ! empty( $postarr['meta_input'] ) ) {
foreach ( $postarr['meta_input'] as $field => $value ) {
update_post_meta( $post_ID, $field, $value );
}
}
where we see how the post meta fields are updated/added with update_post_meta()
.
Here's the inline description for meta_input
:
Array of post meta values keyed by their post meta key. Default empty.
This was added in WordPress 4.4 and here's relevant ticket #20451 for more information.
Note that using the underscore in front of the the meta key _test
will hide it from the custom fields metabox in the post edit screen.