Home › Forums › Backend Issues (wp-admin) › Populate select field with directories › Reply To: Populate select field with directories
i think it is possible when you “adapt” this dynamically-populate-a-select-fields-choices and combine it with your function to scan the directories.
for first dropdown do something like that:
function acf_load_color_field_choices( $field ) {
// reset choices
$field['choices'] = array();
//fill here your array into the variable $choices
$choices = php glob() function that you have;
//
// loop through array and add to field 'choices'
if( is_array($choices) ) {
foreach( $choices as $choice ) {
$field['choices'][ $choice ] = $choice;
}
}
// return the field
return $field;
}
add_filter('acf/load_field/name=color', 'acf_load_color_field_choices');
for second dropdown, you need to get the value of first dropdown and do nearly same again.
hope i have understand you right, and this answer help. or at least lead you to the right direction
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.