WC_Breadcrumb::term_ancestors
Add crumbs for a term.
Method of the class: WC_Breadcrumb{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->term_ancestors( $term_id, $taxonomy );
- $term_id(int) (required)
- Term ID.
- $taxonomy(string) (required)
- Taxonomy.
WC_Breadcrumb::term_ancestors() WC Breadcrumb::term ancestors code WC 10.6.2
protected function term_ancestors( $term_id, $taxonomy ) {
$ancestors = get_ancestors( $term_id, $taxonomy );
$ancestors = array_reverse( $ancestors );
foreach ( $ancestors as $ancestor ) {
$ancestor = get_term( $ancestor, $taxonomy );
if ( ! is_wp_error( $ancestor ) && $ancestor ) {
$this->add_crumb( $ancestor->name, get_term_link( $ancestor ) );
}
}
}