Banging my head on the wall now. name= works. I made a stupid mistake and had a duplicate field in my functions with a slightly different name and I was calling the wrong one. Thanks so much elliot! It’s great to understand the filters now.
Sorry about that – I believe we have the correct use of the variable now, but it doesn’t seem to be working correctly. Here’s everything I know:
'name' => 'select_waiting_list',
with 'choices' => array(),
in functions.php.function get_waiting_lists( $field ) {
$field['choices'] = 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 ) {
$choices[$list->ID] = $list->post_title;
}
$field['choices'] = $choices;
wp_reset_postdata();
return $field;
}
add_filter('acf/load_field/name=select_waiting_list', 'get_waiting_lists');
array(1) { ["choices"]=> array(2) { [449]=> string(26) "Waiting List - Millionaire" [623]=> string(29) "Waiting List - Small Business" } }
<select id="acf-field-connect_waiting_list" class="select" name="fields[field_5272b350a4105]"><option value="null">- Select -</option><option value="choices"></option></select>
Thank you again, so much, for your help sorting this out. You guys have such great support.
– Ross
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');
Thanks for the lead, Elliot! I have to believe that someone else has run across this and come up with a solution… Any way I could get some direction on what script to use in the function? Thanks so much for your help!
PHP export worked flawlessly. Simple steps for anyone else who comes across this thread:
1) Network Activate Advanced Custom Fields
2) Create Field Groups on the Main Site through the Custom Fields Menu.
3) Use Custom Fields –> Export, select all field groups, Export to PHP
4) Paste the PHP into your (child) theme’s functions.php
5) Go back and trash the fields from the main site so there aren’t duplicates.
You now have ACF fields available network-wide.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.