简体   繁体   中英

Can't get ACF fields after creating a new page

We are developing a crowd-funding platform based on Wordpress' "advanced custom fields". In order to create a new funding-project we fill ACF-fields (in a HTML-form). On submitting we create a new WP-page:

$post = array(
        'post_name'      => $pname,
        'post_title'     => $pname,
        'post_type'      => 'page',
        'post_parent'    => 8,
        'page_template'  => 'project.php'
    );

$this->post_id = wp_insert_post($post); 

Strangely we cannot access the field variables with get_field(" ... ") before we manually click onto "Save" or "Publish" on the page in the Wordpress backend. wp_update_post() or wp_publish_post() make no difference.

Do you have any suggestions?

We just found the solution! Using the field key instead of the field name on filling the fields worked!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM