WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#20451 new enhancement

wp_insert_post() should accept a meta_input argument

Reported by: johnbillion Owned by:
Milestone: Awaiting Review Priority: low
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

wp_insert_post() accepts a tax_input argument to set the post's terms, but there's no similar argument to set the post's meta fields. add_post_meta() must be called for each meta field after wp_insert_post() is called.

I'll do up a patch at some point.

Attachments (1)

20451.diff (464 bytes) - added by CoenJacobs 2 years ago.
Basic fix that loops through provided meta fields and values

Download all attachments as: .zip

Change History (2)

CoenJacobs2 years ago

Basic fix that loops through provided meta fields and values

comment:1 CoenJacobs2 years ago

Provided patch proves that it can be done really easy. This patch does not check for capabilities and there is lots of room for improvement. Just showing how easy it can be.

Now on to if it should be done and what we need to consider before doing so.

Note: See TracTickets for help on using tickets.