Home › Forums › Backend Issues (wp-admin) › Dynamically Load Select Choices with Functions › Reply To: Dynamically Load Select Choices with Functions
I guess I need to use a filter. I modified the function to the following (so $field holds that array I was talking about in the initial post) and added the filter but still no luck… Any ideas? I really appreciate your help!
function get_waiting_lists( $field ) {
$field = array();
// Query Waiting Lists Products
$args = array(
'post_type' => 'memberpressproduct',
'orderby' => 'name',
'order' => 'ASC',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'topics',
'field' => 'id',
'terms' => '22',
'operator' => 'IN'
),
)
);
$lists_array = get_posts( $args );
foreach ( $lists_array as $list ) {
$field[$list->ID] = $list->post_title;
}
wp_reset_postdata();
return $field;
}
add_filter('acf/load_field/name=select_waiting_list', 'get_waiting_lists');
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.