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 badge1 Answer
Reset to default 0Try 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
评论列表(0条)