首页 > 解决方案 > 如果转发器位于组中,如何更新转发器字段

问题描述

我正在尝试这种结构:

组 -> 中继器 -> sub_field

                $value = array(
                    'repeater' => array(

                        array(
                            'repeater_field' => (foreach)$names

                        )
                    ) 

                );

                update_sub_field( $group_name, $value, $post_id );

标签: wordpressadvanced-custom-fields

解决方案


您将转发器作为组字段的子字段并将其作为转发器循环。

如果您需要帖子 ID,则如果您不在帖子之外,请阅读有关update_sub_field的信息。

if( have_rows('group') ):
            while( have_rows('group') ) :
                the_row();
                if( have_rows('repeater') ):
                    while( have_rows('repeater') ) :
                        the_row();
                        $value = update_sub_field('sub_field', "update text");
                    endwhile;
                endif;
            endwhile;
        endif;

推荐阅读