Support

Account

Home Forums General Issues Populate ACF fields programmatically

Helping

Populate ACF fields programmatically

  • Hi! I have a store with over 30 items, and I just added a bunch of custom fields for products. My question now is, is there a way to pro grammatically fill these fields without having to go product by product? My logic… create a CSV file, upload as a table in the database, and run a while loop with this:

    while($row = mysqli_fetch_assoc($con,$query){
    update_field('field', $row['field'], $row['prod_id');
    update_field('field', $row['field'], $row['prod_id');
    update_field('field', $row['field'], $row['prod_id');
    ....
    }

    Is this possible without having a pre-existing values since these fields were created AFTER the products were placed in the shop?

  • Without having data already in the fields you should use the field keys and not the field names. Other than that your basic idea as I understand it should work.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Populate ACF fields programmatically’ is closed to new replies.