How to access repeater field of a custom field?

I have a custom post type called donation_group it has a custom_field called donate_pages which is a repeater field. Thi

I have a custom post type called donation_group it has a custom_field called donate_pages which is a repeater field. This donate_pages has again fields called donation_object and amount_received. I want to access these custom fields in my controller ie php file.

This is the code I have tried so far

 $donation_group_posts = Timber::get_posts(array(
        'post_type' => 'donation_group'
    ));

    foreach ( $donation_group_posts as $dg_post ) {
        $dg_donate_pages = $dg_post -> donate_pages;
        echo "dg_donate_pages", $dg_donate_pages;
    }

When I echo dg_donate_pages, I am only getting the number of rows that repeater field has. How can I get its values?

I have a custom post type called donation_group it has a custom_field called donate_pages which is a repeater field. This donate_pages has again fields called donation_object and amount_received. I want to access these custom fields in my controller ie php file.

This is the code I have tried so far

 $donation_group_posts = Timber::get_posts(array(
        'post_type' => 'donation_group'
    ));

    foreach ( $donation_group_posts as $dg_post ) {
        $dg_donate_pages = $dg_post -> donate_pages;
        echo "dg_donate_pages", $dg_donate_pages;
    }

When I echo dg_donate_pages, I am only getting the number of rows that repeater field has. How can I get its values?

Share Improve this question asked Dec 24, 2019 at 14:53 PraneethaPraneetha 1031 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Try this:

foreach ( $donation_group_posts as $dg_post ) {
    $dg_id = $dg_post->ID;

    if(have_rows('YOUR_REPEATER_SLUG', $dg_id)){
        while(have_rows('YOUR_REPEATER_SLUG', $dg_id)) : the_row();
            echo get_sub_field('YOUR_FIELD_SLUG');
        endwhile;
    }

}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744880927a4598832.html

相关推荐

  • How to access repeater field of a custom field?

    I have a custom post type called donation_group it has a custom_field called donate_pages which is a repeater field. Thi

    1天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信