WordPress:ACF将行添加到转发器字段 [英] WordPress: ACF add rows to a repeater field
问题描述
我正在寻找一种在ACF Pro中将行添加到转发器字段的方法。我发现此帖子,但解决方案帖子似乎无效。我将描述我的问题:
I'm looking for a way to add rows to a repeater field in ACF Pro. I found this post but the solution post doesn't seem to work. I will describe my problem:
我有一个名为 gebruikers的自定义帖子类型,一个名为 logins的转发器字段以及一个可以包含名为 datum的字段的行。我希望能够在基准字段的新行中添加一个值。
I have a custom post type called "gebruikers", a repeater field called "logins" and a rows that can have a field called "datum". I would like to be able to add a value to a new row in the field "datum". Is this possible?
到目前为止,我的代码是
My code so far:
$field_key = "logins";
$user_id = "gebruiker_23";
$value = get_field($field_key, $user_id);
$value[] = array('date' => date('Y-m-d H:i:s'));
update_field( $field_key, $value, $user_id );*/
推荐答案
我认为您正在寻找add_row函数。
https://www.advancedcustomfields.com/resources/add_row/
I think the add_row function is what you are looking for. https://www.advancedcustomfields.com/resources/add_row/
$row = array(
'datum' => 'new value',
);
$i = add_row( 'logins', $row );
这篇关于WordPress:ACF将行添加到转发器字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!