Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




_get_term_hierarchy [ WordPress Function ]

_get_term_hierarchy ( $taxonomy )
Access:
  • private
Parameters:
  • (string) $taxonomy Taxonomy Name
Uses:
Returns:
  • (array) Empty if $taxonomy isn't hierarchical or returns children as Term IDs.
Defined at:



Retrieves children of taxonomy as Term IDs.

Source


<?php
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($taxonomy, array('get' => 'all''orderby' => 'id''fields' => 'id=>parent'));
    foreach ( 
$terms as $term_id => $parent ) {
        if ( 
$parent )
            
$children[$parent][] = $term_id;
    }
    
update_option("{$taxonomy}_children"$children);

    return 
$children;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics