acf_decode_taxonomy_terms()
acf_decode_taxonomy_terms
This function decodes the $taxonomy:$term strings into a nested array
No Hooks.
Returns
(Array).
Usage
acf_decode_taxonomy_terms( $strings );
- $strings
- .
Default:false
Changelog
| Since 5.0.0 | Introduced. |
acf_decode_taxonomy_terms() acf decode taxonomy terms code ACF 6.8.8
function acf_decode_taxonomy_terms( $strings = false ) {
// bail early if no terms
if ( empty( $strings ) ) {
return false;
}
// vars
$terms = array();
// loop
foreach ( $strings as $string ) {
// vars
$data = acf_decode_taxonomy_term( $string );
$taxonomy = $data['taxonomy'];
$term = $data['term'];
// create empty array
if ( ! isset( $terms[ $taxonomy ] ) ) {
$terms[ $taxonomy ] = array();
}
// append
$terms[ $taxonomy ][] = $term;
}
// return
return $terms;
}