Support

Account

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