/**
* Populate the link selection of the quick links for use on the dashboard
*/
add_filter('acf/load_field/key=field_5776bde6e0201', 'jb_populate_select_w_tax');
function jb_populate_select_w_tax($field) {
static $list = null;
// reset choices
$field['choices'] = array();
// return cached list
if($list !== null) { return $list; }
// initialize choice list
$list = array();
// find the categories we want to add
$terms = get_terms( array(
'taxonomy' => array('tax-slug-1','tax-slug-2'),
'hide_empty' => false,
'parent' => 0 //we are only getting the top level taxonomies here
) );
if(is_array($terms) && (count($terms) > 0)) {
foreach($terms as $term) {
$list[$term->term_id] = $term->name;
$child_terms = get_terms( array(
'taxonomy' => array('tax-slug-1','tax-slug-2'),
'hide_empty' => false,
'parent' => $term->term_id //now we want this taxonomy's children
) );
if(! empty($child_terms)){
foreach($child_terms as $child_term){
$list[$child_term->term_id] = '- '.$child_term->name;
}
}
}
}
// set choice list & return updated field
$field['choices'] = $list;
return $field;
}