Home › Forums › Add-ons › Repeater Field › query and return rows from repeater › Reply To: query and return rows from repeater
Yeah, I guess I could have been more clear on that. I got it to work this way:
function populate_cpt_titles( $form ) {
foreach ( $form['fields'] as $field ) {
if ( $field->type != 'select' || strpos( $field->cssClass, 'populate_al_products' ) === false ) {
continue;
}
$field->placeholder = 'Select an your product';
$args = [
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'post_title',
'post_type' => 'al_product',
'post_status' => 'publish',
];
$custom_posts = get_posts( $args );
$options = [];
foreach( $custom_posts as $custom_post ) {
$options[] = ['text' => $custom_post->post_title, 'value' => $custom_post->post_title];
$subfields = get_field('product_variations', $custom_post->ID);
if ($subfields) {
foreach ($subfields as $subfield) {
$options[] = ['text' => $subfield['part_number'], 'value' => $subfield['part_number'] ];
}
}
}
$field->choices = $options;
}
return $form;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.