How to update custom fields using the wp_insert_post() function?
Question
The WordPress function is used for submitting data programatically. Standard fields to submit to incude the content, excerpt, title, date and many more.
What there is no documentation for is how to submit to a custom field. I know it is possible with the add_post_meta($post_id, $meta_key, $meta_value, $unique);
function.
But, how to include that into the standard wp_insert_post
function?
<?php
$my_post = array(
'post_title' => $_SESSION['booking-form-title'],
'post_date' => $_SESSION['cal_startdate'],
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_type' => 'booking',
);
wp_insert_post( $my_post );
?>
0
4 months
0 Answers
11 views
0
Leave an answer
You must login or register to add a new answer .