wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.
_get_term_hierarchy is private and should not be used in themes or plugins directly.
_get_term_hierarchy › WordPress Function
Od2.3.0
Przestarzałyn/a
› _get_term_hierarchy ( $taxonomy )
| Dostęp: |
|
| Parametry: |
|
| Powrót: |
|
| Zdefiniowane na: |
|
| Codex: |
Retrieves children of taxonomy as term IDs.
Powiązane Funkcje: get_template_hierarchy, get_page_hierarchy, get_term_meta, get_term_by, get_term_field
Źródło
function _get_term_hierarchy( $taxonomy ) {
if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
return array();
}
$children = get_option( "{$taxonomy}_children" );
if ( is_array( $children ) ) {
return $children;
}
$children = array();
$terms = get_terms(
array(
'taxonomy' => $taxonomy,
'get' => 'all',
'orderby' => 'id',
'fields' => 'id=>parent',
'update_term_meta_cache' => false,
)
);
foreach ( $terms as $term_id => $parent ) {
if ( $parent > 0 ) {
$children[ $parent ][] = $term_id;
}
}
update_option( "{$taxonomy}_children", $children );
return $children;
}