wp_insert_post add meta_input

meta_input is just a single-dimension array as key => value:

'meta_input' => array(
    'name' => $post['name'],
    'city' => $post['city']
)

tax_input is slightly different, with tax as key and an array of values:

'tax_input' => array( 
    'taxonomy_name' => array( 
        'term', 
        'term2', 
        'term3' 
    ) 
)

Note that for tax_input to work, the user currently logged in when the code runs has to have the capability to manage that taxonomy, otherwise it will fail silently.

Leave a Comment