这在今天的文档中并不是非常清楚,但事实证明add_row
只有在已经保存现有行的情况下才有效.当您第一次尝试填充转发器字段时,您必须使用update_field
而不是传递值数组的数组.
// Populate "Name" update_field('field_566e360961c2f', 'John Doe', $wp_identifier); // Populate "Sponsors" $new_sponsors = array(); foreach($sponsors as $sponsor) { // Define "Sponsor Name" $new_sponsor = array( 'field_566e32fb943a5' => 'Beats and Corn Companye' ); $new_sponsors[] = $new_sponsor; } update_field('field_566e32bd943a4', $new_sponsors, $wp_identifier);