So I have made some kind of importer(From another non WP db to my WP db) which handles everything in a click of a button.

Now it does correctly create a post type although one of the custom fields made with ACF in which I have to place the ID from the other DB is not filling in correctly and I did this according to update_post_meta. Now I have no idea what the issue is because when I look into my Wordpress DB it shows that it adds it correctly into the database but it does not add(Better said Show) WITH the custom post in the WP-Admin.

This is the code i've used:

<form action="" method="post">
    <input type="submit" value="Test" id="submit" name="submit">

    foreach ($result as $c) {
        $postargs = array(
            'post_title'   => $c->member_name,
            'post_status'  => 'draft',
            'post_type'    => 'bedrijf'

        $thisid = wp_insert_post ( $postargs, true);

        if ( is_wp_error($thisid) ) {
            return get_error_codes();
        } else {  
            update_post_meta( $thisid, $meta_key, $c->memberID);



A screenshot from my DB showing that it does add(Yes the meta key is correct as I only have one custom field). The meta value is also correct as I put it on LIMIT 1 in the query I have so it shows the first value of the DB only.

DB Image

EDIT: To be exact it adds it in the wp_postmeta table.

  • Ok, so the actual issue is that it's not showing it with the CPT (frontend or backend?) and not that it's not adding it to the database (the question-title seems to imply that)?
    – Hiranthi
    Mar 18 '14 at 9:24
  • It is showing it in the database of Wordpress but it's showing as empty in the WP-admin for some reason.
    – David H
    Mar 18 '14 at 9:26
  • could you add a screenshot of that in the wp-admin?
    – Hiranthi
    Mar 18 '14 at 9:56
  • I solved it my friend but thanks for the help anyway. I was using the wrong property for ACF, only update_field is applicable. Wp-admin would just show 2 fields by the way.
    – David H
    Mar 18 '14 at 10:07

Found the solution in this post:

update_post_meta and update_field ony working when saving the post

The solution is to use update_field because update_post_meta uses a different method to update fields than ACF does. Do note that this is the correct order of using the code update_field($meta_key, $meta_value, $post_ID);.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.