Home › Forums › General Issues › Inserting CSV data into custom fields › Reply To: Inserting CSV data into custom fields
I think I see what’s going on, maybe this will help
for ($i = 1, $numInventory = count($inventory); $i < $numInventory; $i++) {
// for each row of the input, create a new post
$post_information = array(
'post_title' => 'test '.$i,
'post_type' => 'vehicle',
'post_status' => 'publish'
);
$postID = wp_insert_post( $post_information );
// the following assumes that the order of
// the columns in the csv matches
// the order of the list of field keys
for ($m = 0, $numSub = count($inventory[$i]); $m < $numSub; $m++) {
// use the field key for $m column
update_field($field_keys[$m], $inventory[$i][$m], $postID);
} // end for $m
} // end for $i
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.