Yes, wp_insert_post()
will automatically insert new postmeta as well.
I just tried out your exact code and it worked. And the reason behind this could be quite simple: In WordPress, meta info for a post is only a key and value pair. There is no strict rule that keys have to be defined somewhere, so you can easily insert your own at any given moment.
Related Posts:
- What is “meta_input” parameter in wp_insert_post() used for?
- Adding custom fields (post meta) before/during wp_insert_post()
- Can’t get post ID using wp_insert_post_data
- how to upload a image from frontend with wp_insert_post and also update_post_meta?
- Can wp_insert_post_data filter be used to save custom field data?
- WP Insert post with post_thumbnail
- Insert posting automatically based in acf field
- Post meta data not showing in frontend, until hitting ‘update’ button
- add multiple values (array) to post meta_input
- ORDER BY custom field value
- Best way to programmatically remove a category/term from a post
- display specific custom fields
- Add new “Insert Into Post” button with another function
- Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
- How to add new custom page or post blocks?
- Transients vs CRON +Custom Fields: Caching Data Per Post
- How to update serialized data in the user meta data
- Unable to save datetime custom meta field using update_post_meta() function
- Best way to allow manageable social media URLS?
- Custom Field Multiple Clauses
- Adding a custom field or metabox to the post-thumbnail widget?
- Using WP Query to search by multiple meta fields
- Get aggregate list of all custom fields for entire blog
- Sort by posts that have a featured image?
- WP_Query display next custom post from today’s date
- Can ordering post list by meta_value cause performance issue?
- Meta_query and numeric comparison [closed]
- Title and post URL based on custom fields?
- woocommerce product custom field
- Multiple relationships in a query
- How Meta Data is different from Custom Fields of POST/PAGE in WordPress
- two custom fields question
- How to save multiple options from a dropdown in user profile
- How to display multiple images in custom field
- How to show a gloabl message on a user profile page (in back end)?
- How to add a new meta key and assign timestamp to posts
- Display the contents of a custom field of a page on their child
- Read / Watch / Listen times – meta
- Login WP – Connect single field to an external api
- Advanced search by two criteria – sort by location and date (ascending or descending)
- adding extra wordpress user info from registration form
- Custom Meta Box (SELECT) Not Saving
- Collect user custom field in product page woocommerce
- Turn raw url into clickable links
- Displaying a custom field
- meta fields for the whole wordpress site
- Advanced Custom Fields functionality without plugin
- Get post ids sorted by meta_key
- Advanced Custom Fields Plugin – Unable to get URL from post_object
- Plot location on Google map using full address specified in custom field
- Unable to get specific value from post meta
- 3.8 Media Upload and Custom Meta Box
- Displaying Custom Field Array
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- Let’s Create Custom Field Template Documentation
- WordPress Settings API Repeatable fields
- WordPress creates new lines in postmeta table on post update
- How to add custom filed value after in wp post title
- Accessing Custom Fields on Pages
- How to Pass values to Custom Field through PHP in WordPress Posts?
- Display a different image for each page with editor
- how to add product subscription field in woocommerce plugin
- How can I change the publish date based on a custom field?
- WP_query multiple custom fields not working
- Help with this custom field conditional if no field is set display nothing
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- Only admin should be able to add a particular custom field
- Automatically Add Custom Fields Value as Tags
- How to display custom fields in hestia theme
- How to update only certain custom fields in a the cache of a page?
- Custom date column in user table not sorting correcting
- pass custom value from single.php to another file via get
- How to speed up post list slowed by update_meta_cache()?
- Custom Fields displaying in single line
- variable not passed correctly to database using custom field
- WordPress Blocks, setAttributes not saving
- How do i call up default post title in custom posts
- Custom Field URL + description
- How to save multiple custom user profile fields using repeater JQuery
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Issue on Creating Checkbox Field On Custom Post type
- Why does this javascript search function in the WordPress Admin not work?
- author global display format
- Problem saving meta data
- Term specific featured post on taxonomy archive pages
- WP_query returns error when used for custom widget
- Saving metadata of related post on save_post
- Custom field value link title
- How to Order Posts by Custom Fields?
- added a meta box to post however when saving menu while debug on throws a warning
- How can i get the actor birthday by date?
- Post rating using Custom Field
- Inserting custom fields into new-post.php without using the Custom Fields Template plugin?
- How can I attach files without using a plugin?
- Advanced Custom Fields for Header that are Editable from a Page [closed]
- Change Fields of Comments and make them searchable?
- Shortcode not picking up custom field
- Order by a meta field in query loop
- Conditional display based on ACF checkbox
- How to add an ACF only for parent term?